Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion src/lib/app/RvCommon/GLView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,40 @@ namespace Rv

if (!session->isFullScreen())
{
m_doc->resizeToFit(false, false);
// We are painting the first non-empty
// render, and user has selected the option
// "Resize window to first image loaded".
// So we pass firstTime=true to the resize
// function.
m_doc->resizeToFit(false, true);
m_doc->center();
TWK_GLDEBUG;

// 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.
//
// As a result, the main window is now in a state where
// it has resized, but the user can't manually resize
// it smaller than the image. To get the main window
// back in an expected state, we call this function
// once more, in a singleShot, so QMainWindow::resize
// can safely run after the paintGL handling is complete.
QTimer::singleShot(0, this,
[this]()
{
m_doc->resizeToFit(false, false);
m_doc->center();
TWK_GLDEBUG;
});
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/lib/app/RvCommon/RvDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1283,11 +1283,14 @@ namespace Rv
m_glView->setContentSize(int(w), int(h));
m_glView->setMinimumContentSize(int(w), int(h));
m_glView->updateGeometry();

// Note: We don't call this the first time,
// as it will reset the image size to its
// previous scale.
m_resetPolicyTimer->start();
}
DB("resizeToFit final resulting size w " << m_glView->width() << " h " << m_glView->height());

m_resetPolicyTimer->start();

if (placement)
{
int x = ssize.left() + int((sw - w) / 2);
Expand Down