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

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