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

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