diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index f2590f9c54..fd4ced078d 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -256,7 +256,7 @@ private: void deliverCall(QObject *object, int flags, const QDBusMessage &msg, const QVector &metaTypes, int slotIdx); - bool isServiceRegisteredByThread(const QString &serviceName) const; + bool isServiceRegisteredByThread(const QString &serviceName); QString getNameOwnerNoCache(const QString &service); diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 1fef6d4d49..6b6ac6bc62 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -2488,12 +2488,15 @@ void QDBusConnectionPrivate::unregisterServiceNoLock(const QString &serviceName) serviceNames.removeAll(serviceName); } -bool QDBusConnectionPrivate::isServiceRegisteredByThread(const QString &serviceName) const +bool QDBusConnectionPrivate::isServiceRegisteredByThread(const QString &serviceName) { if (!serviceName.isEmpty() && serviceName == baseService) return true; - QStringList copy = serviceNames; - return copy.contains(serviceName); + if (serviceName == dbusServiceString()) + return false; + + QDBusReadLocker locker(UnregisterServiceAction, this); + return serviceNames.contains(serviceName); } void QDBusConnectionPrivate::postEventToThread(int action, QObject *object, QEvent *ev)