diff options
author | Jan Arne Petersen <jpetersen@openismus.com> | 2012-10-15 10:30:55 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-31 23:55:00 (GMT) |
commit | 9b4bd98744623f81b7b0950e207209f0c19adb46 (patch) | |
tree | 9078f55d9a95e13214beb5ff0aae9fddfe78d4b5 /src/dbus/qdbusintegrator.cpp | |
parent | 7c60bee5678aaf5ca2141de65d173a4704bb259e (diff) | |
download | Qt-9b4bd98744623f81b7b0950e207209f0c19adb46.zip Qt-9b4bd98744623f81b7b0950e207209f0c19adb46.tar.gz Qt-9b4bd98744623f81b7b0950e207209f0c19adb46.tar.bz2 |
Fix QDBusServer with more than one connection
Create a new QDBusConnectionPrivate for every new connection in
qDBusNewConnection instead of creating a single QDBusConnectionPrivate
in the QDBusServer constructor which gets assigned the latest connected
DBusConnection in qDBusNewConnection (and loses track on all previous
DBusConnections).
Also extend tst_QDBusConnection::registerObjectPeer() test with multiple
connections to the server.
Task-Number: QTBUG-24921
Change-Id: I4341e8d48d464f3fe0a314a6ab14f848545d65a0
(cherry picked from qtbase/a386194f9952683c0be5028f2b7f0ce9617fe404)
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/dbus/qdbusintegrator.cpp')
-rw-r--r-- | src/dbus/qdbusintegrator.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
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" |