aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Hartmetz <andreas@ixgreen.de>2021-03-05 12:41:06 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-03-12 19:43:47 +0000
commit8fcf75ac7d32ac647b9fb7a09e9183143e1efe59 (patch)
treeba0f9f46c43c2e41ed9ff6d2f0979da6111702e5 /src
parentd1ef40ff4d81b5d544c08495d3237e0ddff803e9 (diff)
QQuickWindow: don't leak old screenChanged connections
Connections could accumulate. Because the newest one was invoked last due to how signal-slot invocations are ordered, rendering was correct, but the stale connections caused unnecessary updates (and wasted a small amount of memory). This comes from a misunderstanding I had at the time about how QMetaObject::Connection works. Destroying or overwriting one does not affect the actual connection. While at it, also modernize the connect(). Change-Id: Idde81bdbff8947ed517bf2740d623a395c0acb74 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> (cherry picked from commit 9f8292d48913c5bc50377749c2b3e030cf16d703) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/quick/items/qquickwindow.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index d71e6ec1a5..85b59aa7ba 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -435,15 +435,14 @@ void QQuickWindow::physicalDpiChanged()
void QQuickWindow::handleScreenChanged(QScreen *screen)
{
Q_D(QQuickWindow);
+ 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.
- d->physicalDpiChangedConnection = connect(screen, SIGNAL(physicalDotsPerInchChanged(qreal)),
- this, SLOT(physicalDpiChanged()));
- } else {
- disconnect(d->physicalDpiChangedConnection);
+ d->physicalDpiChangedConnection = connect(screen, &QScreen::physicalDotsPerInchChanged,
+ this, &QQuickWindow::physicalDpiChanged);
}
d->forcePolish();