summaryrefslogtreecommitdiff
path: root/vcl/qt5
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2024-09-27 10:11:02 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2024-09-28 09:34:06 +0200
commit95283b72cf60208fb1df0fd1eb5ec021cd43eb9e (patch)
tree00b7500fbb3088777cb2d78b5e14e42f315de0b6 /vcl/qt5
parent0218519537f6b77e06ae1e3020ed681b5a4f812c (diff)
qt: Just ignore request to set frame to invalid screen number
Instead of setting the screen to the primary screen, just ignore the request when QtFrame::SetScreenNumber gets called with an invalid screen number. The previous handling was introduced in commit f806a2832aee62efc0e0404f7c24d53aaaf814d0 Date: Mon Oct 22 16:35:21 2018 +0200 tdf#120451: Use primary screen if requested screen doesn't exist to fix a crash, but just ignoring the request avoids crashing, too. (`git show --ignore-space-change` helps to see the "actual" change more easily.) Change-Id: I272ec64f89ef835161fa68c7fdc8cd0e407b7495 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174033 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
Diffstat (limited to 'vcl/qt5')
-rw-r--r--vcl/qt5/QtFrame.cxx48
1 files changed, 22 insertions, 26 deletions
diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx
index 1c2e81938ecb..03a04b459244 100644
--- a/vcl/qt5/QtFrame.cxx
+++ b/vcl/qt5/QtFrame.cxx
@@ -1288,39 +1288,35 @@ void QtFrame::SetScreenNumber(unsigned int nScreen)
return;
QList<QScreen*> screens = QApplication::screens();
- if (static_cast<int>(nScreen) < screens.size() || m_bFullScreenSpanAll)
+ if (static_cast<int>(nScreen) >= screens.size() && !m_bFullScreenSpanAll)
{
- QRect screenGeo;
+ SAL_WARN("vcl.qt", "Ignoring request to set invalid screen number");
+ return;
+ }
- if (!m_bFullScreenSpanAll)
- {
- screenGeo = QGuiApplication::screens().at(nScreen)->geometry();
- pWindow->setScreen(QApplication::screens().at(nScreen));
- }
- else // special case: fullscreen over all available screens
- {
- assert(m_bFullScreen);
- // left-most screen
- QScreen* pScreen = QGuiApplication::screenAt(QPoint(0, 0));
- // entire virtual desktop
- screenGeo = pScreen->availableVirtualGeometry();
- pWindow->setScreen(pScreen);
- pWindow->setGeometry(screenGeo);
- nScreen = screenNumber();
- }
+ QRect screenGeo;
- // setScreen by itself has no effect, explicitly move the widget to
- // the new screen
- asChild()->move(screenGeo.topLeft());
+ if (!m_bFullScreenSpanAll)
+ {
+ screenGeo = QGuiApplication::screens().at(nScreen)->geometry();
+ pWindow->setScreen(QApplication::screens().at(nScreen));
}
- else
+ else // special case: fullscreen over all available screens
{
- // index outta bounds, use primary screen
- QScreen* primaryScreen = QApplication::primaryScreen();
- pWindow->setScreen(primaryScreen);
- nScreen = static_cast<sal_uInt32>(screenNumber());
+ assert(m_bFullScreen);
+ // left-most screen
+ QScreen* pScreen = QGuiApplication::screenAt(QPoint(0, 0));
+ // entire virtual desktop
+ screenGeo = pScreen->availableVirtualGeometry();
+ pWindow->setScreen(pScreen);
+ pWindow->setGeometry(screenGeo);
+ nScreen = screenNumber();
}
+ // setScreen by itself has no effect, explicitly move the widget to
+ // the new screen
+ asChild()->move(screenGeo.topLeft());
+
maGeometry.setScreen(nScreen);
}