qt5-qtdeclarative/0039-QQuickWindow-don-t-leak-old-screenChanged-connection.patch
2021-11-17 12:15:40 -06:00

51 lines
2.1 KiB
Diff

From d7ede3462d7e12e4fa60a6efa1b83e2157be4b00 Mon Sep 17 00:00:00 2001
From: Andreas Hartmetz <andreas@ixgreen.de>
Date: Fri, 5 Mar 2021 12:41:06 +0100
Subject: [PATCH 39/41] 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().
Pick-to: 5.15 6.0 6.1
Change-Id: Idde81bdbff8947ed517bf2740d623a395c0acb74
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
(cherry picked from commit 9f8292d48913c5bc50377749c2b3e030cf16d703)
---
src/quick/items/qquickwindow.cpp | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 9ff91eb9a0..fbb807ca96 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -450,15 +450,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();
--
2.33.1