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>
This commit is contained in:
parent
751cbbd6b1
commit
de609d84b9
@ -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
|
||||
{
|
||||
|
@ -27,6 +27,7 @@ class Q_GUI_EXPORT QGenericUnixServices : public QPlatformServices
|
||||
{
|
||||
public:
|
||||
QGenericUnixServices();
|
||||
~QGenericUnixServices();
|
||||
|
||||
QByteArray desktopEnvironment() const override;
|
||||
|
||||
@ -41,6 +42,9 @@ public:
|
||||
private:
|
||||
QString m_webBrowser;
|
||||
QString m_documentLauncher;
|
||||
#if QT_CONFIG(dbus)
|
||||
QMetaObject::Connection m_watcherConnection;
|
||||
#endif
|
||||
bool m_hasScreenshotPortalWithColorPicking = false;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user