aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-07-20 16:39:08 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-07-21 04:19:21 +0000
commitc50aefa2bc62f3c3f065c1aa640aaa5e0e58abcd (patch)
tree639d2bc70e9cffe8873e5759b1ff17808baf9bbd /src/quick/items
parent696d607d8596bd57e957a23778382d546196ef34 (diff)
Handle QScreen::physicalDotsPerInchChanged changes for the initial screen
We connect to the signal when the screens change (in QQuickWindow::handleScreenChanged), but never for the initial screen. Not connecting means that changing the DPR of the initial screen doesn't re-render QQuickItems with the new DPR, which was in particular visible for QQuickImage when displaying SVGs. Task-number: QTBUG-94622 Change-Id: I44ff3f8f3713d5a7bba8b6b8b4d5ca14530fe373 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> (cherry picked from commit 7e39a2204382a78ac6ff1e32dfe29dcbce65004c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/quick/items')
-rw-r--r--src/quick/items/qquickwindow.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 344a767afb..3ab9313102 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -450,12 +450,13 @@ void QQuickWindow::physicalDpiChanged()
void QQuickWindow::handleScreenChanged(QScreen *screen)
{
Q_D(QQuickWindow);
+ // we connected to the initial screen in QQuickWindowPrivate::init, but the screen changed
disconnect(d->physicalDpiChangedConnection);
if (screen) {
physicalDpiChanged();
// When physical DPI changes on the same screen, either the resolution or the device pixel
// ratio changed. We must check what it is. Device pixel ratio does not have its own
- // ...Changed() signal.
+ // ...Changed() signal. Reconnect, same as in QQuickWindowPrivate::init.
d->physicalDpiChangedConnection = connect(screen, &QScreen::physicalDotsPerInchChanged,
this, &QQuickWindow::physicalDpiChanged);
}
@@ -707,8 +708,13 @@ void QQuickWindowPrivate::init(QQuickWindow *c, QQuickRenderControl *control)
Q_ASSERT(windowManager || renderControl);
- if (QScreen *screen = q->screen())
- devicePixelRatio = screen->devicePixelRatio();
+ if (QScreen *screen = q->screen()) {
+ devicePixelRatio = screen->devicePixelRatio();
+ // if the screen changes, then QQuickWindow::handleScreenChanged disconnects
+ // and connects to the new screen
+ physicalDpiChangedConnection = QObject::connect(screen, &QScreen::physicalDotsPerInchChanged,
+ q, &QQuickWindow::physicalDpiChanged);
+ }
QSGContext *sg;
if (renderControl) {