Skip to content

fix: Fix QMainWindow Resize Crash in Qt6#1082

Open
williamwira wants to merge 1 commit intoAcademySoftwareFoundation:mainfrom
williamwira:review-wwira-1063
Open

fix: Fix QMainWindow Resize Crash in Qt6#1082
williamwira wants to merge 1 commit intoAcademySoftwareFoundation:mainfrom
williamwira:review-wwira-1063

Conversation

@williamwira
Copy link
Contributor

@williamwira williamwira commented Jan 24, 2026

Linked issues

Fixes #1063

Summarize your change.

On the GLView's first paintGL routine, the Rv Window's resizeToFit function is now called from inside a singleShot. This causes it to run after the first paintGL completes, which avoids the state that previously caused the crash.

Describe the reason for the change.

OpenRV, when built with the VFX2024 option which includes Qt6 6.5.3, had a crash regression. The crash would occur when resizing the main window after the preference "Fit Window to First Media Loaded" executed.

Describe what you have tested and on which operating system.

Tested on Linux RHEL 9.6. Made sure the steps below no longer resulted in a crash:

  1. Build OpenRV with Qt 6.5.3 and the rvcfg flag -DRV_VFX_CY2024=1
  2. Make sure RV > Preferences > Fit Window to First Media Loaded is active
  3. From command line open RV with: rv colorchart,start=1,end=2,width=1920,height=804,fps=24.movieproc
  4. After image loads, attempt to resize RV window. RV previously would crash, but should now should behave as expected.
  5. In RV, activate menu option View > Lock Pixel Scale During Resize.
  6. Close RV, then reopen with same command as in step 3. Image should load and resize to 1:1 scale.

AcademySoftwareFoundation#1063)

Signed-off-by: Will Wira <4399853+williamwira@users.noreply.github.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a Qt6 crash regression when resizing the main window after the initial “fit to first media” resize by deferring a follow-up resize until after the first paintGL() completes.

Changes:

  • Treat the first “resize to fit” as a special case (firstTime=true) during the first non-empty render.
  • Schedule a second resizeToFit() via QTimer::singleShot(0, ...) to restore expected resizability after painting.
  • Adjust when m_resetPolicyTimer is started during resizeToFit.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/lib/app/RvCommon/RvDocument.cpp Starts m_resetPolicyTimer only within the resize path and documents first-time behavior.
src/lib/app/RvCommon/GLView.cpp Introduces a queued “second resize” after first paint to avoid the Qt6 crash state.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +379 to +389
// OpenRV Issue #1063
//
// When upgrading Qt6, calling resizeToFit the first time
// previously resulted in a crashable state when
// QMainWindow::resize was called.
//
// Now we skip calling that on the first time (above).
// In resizeToFit, the function also doesn't execute
// "m_resetPolicyTimer->start()" the first time, as that
// interferes with the "Fit Window to First Media Loaded"
// option.
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is ambiguous in “skip calling that” (it reads as if resizeToFit() is skipped, but the code still calls it with firstTime=true). Consider rewording to explicitly say what is skipped on firstTime (e.g., “resizeToFit(firstTime=true) avoids calling QMainWindow::resize / avoids starting m_resetPolicyTimer on the first invocation”) to make the rationale unambiguous for future maintainers.

Copilot uses AI. Check for mistakes.
Comment on lines +397 to +401
QTimer::singleShot(0, this,
[this]()
{
m_doc->resizeToFit(false, false);
m_doc->center();
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This queued lambda dereferences m_doc later, but it only captures this, so it will use whatever m_doc happens to be at callback time (and could be invalid/replaced if the document changes between scheduling and execution). Capture a stable reference at scheduling time (e.g., a QPointer if it’s a QObject, or an owning/weak handle used in this codebase) and use that inside the lambda to ensure the callback targets the intended, still-alive document.

Suggested change
QTimer::singleShot(0, this,
[this]()
{
m_doc->resizeToFit(false, false);
m_doc->center();
auto* const doc = m_doc;
QTimer::singleShot(0, this,
[doc]()
{
if (!doc) return;
doc->resizeToFit(false, false);
doc->center();

Copilot uses AI. Check for mistakes.
@cedrik-fuoco-adsk cedrik-fuoco-adsk added the community Contribution from the Open RV Community label Feb 17, 2026
@cedrik-fuoco-adsk cedrik-fuoco-adsk changed the title Fix QMainWindow Resize Crash in Qt6 fix: Fix QMainWindow Resize Crash in Qt6 Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Contribution from the Open RV Community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: VFX2024 / Qt6: Window Resize Crash Regression after "Fit to First Media loaded"

3 participants