diff options
Diffstat (limited to 'src/dbus')
-rw-r--r-- | src/dbus/qdbusconnection_p.h | 1 | ||||
-rw-r--r-- | src/dbus/qdbusintegrator.cpp | 14 | ||||
-rw-r--r-- | src/dbus/qdbusserver.cpp | 8 |
3 files changed, 15 insertions, 8 deletions
diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index 2443fca..476456a 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -274,6 +274,7 @@ public: QDBusConnection::ConnectionCapabilities capabilities; QString name; // this connection's name QString baseService; // this connection's base service + QStringList serverConnectionNames; ConnectionMode mode; diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 71647e7..0f0b647 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -50,6 +50,7 @@ #include "qdbusargument.h" #include "qdbusconnection_p.h" +#include "qdbusconnectionmanager_p.h" #include "qdbusinterface_p.h" #include "qdbusmessage.h" #include "qdbusmetatype.h" @@ -385,16 +386,21 @@ static void qDBusNewConnection(DBusServer *server, DBusConnection *connection, v // keep the connection alive q_dbus_connection_ref(connection); - QDBusConnectionPrivate *d = static_cast<QDBusConnectionPrivate *>(data); + QDBusConnectionPrivate *serverConnection = static_cast<QDBusConnectionPrivate *>(data); + + QDBusConnectionPrivate *newConnection = new QDBusConnectionPrivate(serverConnection->parent()); + QMutexLocker locker(&QDBusConnectionManager::instance()->mutex); + QDBusConnectionManager::instance()->setConnection(QLatin1String("QDBusServer-") + QString::number(reinterpret_cast<qulonglong>(newConnection)), newConnection); + serverConnection->serverConnectionNames << newConnection->name; // setPeer does the error handling for us QDBusErrorInternal error; - d->setPeer(connection, error); + newConnection->setPeer(connection, error); - QDBusConnection retval = QDBusConnectionPrivate::q(d); + QDBusConnection retval = QDBusConnectionPrivate::q(newConnection); // make QDBusServer emit the newConnection signal - d->serverConnection(retval); + serverConnection->serverConnection(retval); } } // extern "C" diff --git a/src/dbus/qdbusserver.cpp b/src/dbus/qdbusserver.cpp index 6acc770..90bfa6e 100644 --- a/src/dbus/qdbusserver.cpp +++ b/src/dbus/qdbusserver.cpp @@ -72,9 +72,6 @@ QDBusServer::QDBusServer(const QString &address, QObject *parent) } d = new QDBusConnectionPrivate(this); - QMutexLocker locker(&QDBusConnectionManager::instance()->mutex); - QDBusConnectionManager::instance()->setConnection(QLatin1String("QDBusServer-") + QString::number(reinterpret_cast<qulonglong>(d)), d); - QObject::connect(d, SIGNAL(newServerConnection(QDBusConnection)), this, SIGNAL(newConnection(QDBusConnection))); @@ -89,7 +86,10 @@ QDBusServer::~QDBusServer() { if (QDBusConnectionManager::instance()) { QMutexLocker locker(&QDBusConnectionManager::instance()->mutex); - QDBusConnectionManager::instance()->removeConnection(d->name); + Q_FOREACH (const QString &name, d->serverConnectionNames) { + QDBusConnectionManager::instance()->removeConnection(name); + } + d->serverConnectionNames.clear(); } } |