summaryrefslogtreecommitdiffstats
path: root/src/dbus
diff options
context:
space:
mode:
authorJan Arne Petersen <jpetersen@openismus.com>2012-10-15 10:30:55 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-31 23:55:00 (GMT)
commit9b4bd98744623f81b7b0950e207209f0c19adb46 (patch)
tree9078f55d9a95e13214beb5ff0aae9fddfe78d4b5 /src/dbus
parent7c60bee5678aaf5ca2141de65d173a4704bb259e (diff)
downloadQt-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')
-rw-r--r--src/dbus/qdbusconnection_p.h1
-rw-r--r--src/dbus/qdbusintegrator.cpp14
-rw-r--r--src/dbus/qdbusserver.cpp8
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();
}
}