diff options
| author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2024-08-09 18:07:59 +0200 |
|---|---|---|
| committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2024-08-30 23:56:26 +0200 |
| commit | de609d84b9cee4a481d1718c00b09105d8c2ae69 (patch) | |
| tree | 8307e80d993c67c31da85bcfe2eddfa74b1ae311 /src/gui/platform/unix/qgenericunixservices.cpp | |
| parent | 751cbbd6b13d9899e31c19d9db80d1c64a72a8bd (diff) | |
QGenericUnixServices: properly disconnect signals in dtor
Since QGenericUnixServices does not derive from QObject, the connection
to QDBusPendingCallWatcher made in the ctor might outlive the lifetime
of QGenericUnixServices.
Fix it by explicitly disconnecting it in the dtor.
Fixes: QTBUG-125239
Pick-to: 6.8 6.7 6.5
Change-Id: I5fac4fd5831b2dde16b3d7b479a8ee616bfb7e3a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/gui/platform/unix/qgenericunixservices.cpp')
| -rw-r--r-- | src/gui/platform/unix/qgenericunixservices.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/gui/platform/unix/qgenericunixservices.cpp b/src/gui/platform/unix/qgenericunixservices.cpp index bfd2556b1e6..3aa071b8b26 100644 --- a/src/gui/platform/unix/qgenericunixservices.cpp +++ b/src/gui/platform/unix/qgenericunixservices.cpp @@ -385,7 +385,8 @@ QGenericUnixServices::QGenericUnixServices() QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message); auto watcher = new QDBusPendingCallWatcher(pendingCall); - QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher, + m_watcherConnection = + QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher, [this](QDBusPendingCallWatcher *watcher) { watcher->deleteLater(); QDBusPendingReply<QVariant> reply = *watcher; @@ -396,6 +397,13 @@ QGenericUnixServices::QGenericUnixServices() #endif } +QGenericUnixServices::~QGenericUnixServices() +{ +#if QT_CONFIG(dbus) + QObject::disconnect(m_watcherConnection); +#endif +} + QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent) { #if QT_CONFIG(dbus) @@ -534,6 +542,7 @@ bool QGenericUnixServices::openDocument(const QUrl &url) #else QGenericUnixServices::QGenericUnixServices() = default; +QGenericUnixServices::~QGenericUnixServices() = default; QByteArray QGenericUnixServices::desktopEnvironment() const { |
