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

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