Blame SOURCES/0014-QQuickWindow-don-t-leak-old-screenChanged-connection.patch

77f9a9
From f8f6b9d084decbad8ee90880493c413ac90c2911 Mon Sep 17 00:00:00 2001
77f9a9
From: Andreas Hartmetz <andreas@ixgreen.de>
77f9a9
Date: Fri, 5 Mar 2021 12:41:06 +0100
77f9a9
Subject: [PATCH 14/20] QQuickWindow: don't leak old screenChanged connections
77f9a9
77f9a9
Connections could accumulate. Because the newest one was invoked
77f9a9
last due to how signal-slot invocations are ordered, rendering
77f9a9
was correct, but the stale connections caused unnecessary updates
77f9a9
(and wasted a small amount of memory).
77f9a9
This comes from a misunderstanding I had at the time about how
77f9a9
QMetaObject::Connection works. Destroying or overwriting one does
77f9a9
not affect the actual connection.
77f9a9
77f9a9
While at it, also modernize the connect().
77f9a9
77f9a9
Pick-to: 5.15 6.0 6.1
77f9a9
Change-Id: Idde81bdbff8947ed517bf2740d623a395c0acb74
77f9a9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
77f9a9
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
77f9a9
(cherry picked from commit 9f8292d48913c5bc50377749c2b3e030cf16d703)
77f9a9
---
77f9a9
 src/quick/items/qquickwindow.cpp | 7 +++----
77f9a9
 1 file changed, 3 insertions(+), 4 deletions(-)
77f9a9
77f9a9
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
77f9a9
index eea1e93f32..c956c85091 100644
77f9a9
--- a/src/quick/items/qquickwindow.cpp
77f9a9
+++ b/src/quick/items/qquickwindow.cpp
77f9a9
@@ -450,15 +450,14 @@ void QQuickWindow::physicalDpiChanged()
77f9a9
 void QQuickWindow::handleScreenChanged(QScreen *screen)
77f9a9
 {
77f9a9
     Q_D(QQuickWindow);
77f9a9
+    disconnect(d->physicalDpiChangedConnection);
77f9a9
     if (screen) {
77f9a9
         physicalDpiChanged();
77f9a9
         // When physical DPI changes on the same screen, either the resolution or the device pixel
77f9a9
         // ratio changed. We must check what it is. Device pixel ratio does not have its own
77f9a9
         // ...Changed() signal.
77f9a9
-        d->physicalDpiChangedConnection = connect(screen, SIGNAL(physicalDotsPerInchChanged(qreal)),
77f9a9
-                                                  this, SLOT(physicalDpiChanged()));
77f9a9
-    } else {
77f9a9
-        disconnect(d->physicalDpiChangedConnection);
77f9a9
+        d->physicalDpiChangedConnection = connect(screen, &QScreen::physicalDotsPerInchChanged,
77f9a9
+                                                  this, &QQuickWindow::physicalDpiChanged);
77f9a9
     }
77f9a9
 
77f9a9
     d->forcePolish();
77f9a9
-- 
77f9a9
2.35.1
77f9a9