diff options
| author | Marc Mutz <marc.mutz@qt.io> | 2025-03-26 08:06:04 +0100 |
|---|---|---|
| committer | Marc Mutz <marc.mutz@qt.io> | 2025-03-28 06:56:15 +0000 |
| commit | 567da5e3e0070b7a0dd9ba1acbe9347c6cc1d0fe (patch) | |
| tree | 40bda123c7bc3dc75c6f4091e894375258625b9a /src/gui/platform/unix/qdesktopunixservices.cpp | |
| parent | 83af06b0e5d1ca3aa348debd39f88dfbdbf117b8 (diff) | |
QDesktopUnixServices: don't leak the QDBusPendingCallWatcher
When, like in tst_QApplication::qtbug_103611(), a QApplication object
is destroyed without calling exec(), then QDesktopUnixServices leaked
its QDBusPendingCallWatcher, because the connection to the slot that
would deleteLater() the watcher was disconnected, and the watcher had
no QObject parent that would otherwise reap it.
Fix by actually deleting the watcher in ~QDesktopUnixServices(), if
it still exists (which implies disconnecting, of course).
This makes tst_QApplication asan-clean on Linux/X11 (was: "75466 bytes
leaked in 965 allocations").
Amends de609d84b9cee4a481d1718c00b09105d8c2ae69.
Pick-to: 6.9 6.8 6.5
Change-Id: I28a08abdb1be65a8746702ad304282de4e1100d7
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/gui/platform/unix/qdesktopunixservices.cpp')
| -rw-r--r-- | src/gui/platform/unix/qdesktopunixservices.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/gui/platform/unix/qdesktopunixservices.cpp b/src/gui/platform/unix/qdesktopunixservices.cpp index 226bd338a2c..144a33614c2 100644 --- a/src/gui/platform/unix/qdesktopunixservices.cpp +++ b/src/gui/platform/unix/qdesktopunixservices.cpp @@ -393,7 +393,7 @@ QDesktopUnixServices::QDesktopUnixServices() QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message); auto watcher = new QDBusPendingCallWatcher(pendingCall); - m_watcherConnection = + m_watcher = watcher; QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher, [this](QDBusPendingCallWatcher *watcher) { watcher->deleteLater(); @@ -408,7 +408,7 @@ QDesktopUnixServices::QDesktopUnixServices() QDesktopUnixServices::~QDesktopUnixServices() { #if QT_CONFIG(dbus) - QObject::disconnect(m_watcherConnection); + delete m_watcher; #endif } |
