diff options
author | Alberto Mardegan <alberto.mardegan@canonical.com> | 2016-08-09 17:01:37 +0300 |
---|---|---|
committer | Timo Jyrinki <timo.jyrinki@iki.fi> | 2016-09-06 18:22:58 +0000 |
commit | a32217cb551612277d43b3f7c08da85abe3874ac (patch) | |
tree | 70fe1c8af0dcc9b42ee0d61a26a53d0e40a48bed /src/dbus/qdbusintegrator.cpp | |
parent | 43a710df639c695f4c87e4857b8e8b045ab3df76 (diff) |
QDBusServer: delay processing of D-Bus messages
We must ensure that QDBusServer's newConnection() signal has been
processed by the application, before starting processing messages on it.
Task-number: QTBUG-55087
Change-Id: I595329b2f98788dbf9f40558b8c230c0c0817ef8
Reviewed-by: Timo Jyrinki <timo.jyrinki@iki.fi>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/dbus/qdbusintegrator.cpp')
-rw-r--r-- | src/dbus/qdbusintegrator.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 147966b9b0..878a58294c 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -309,9 +309,21 @@ static void qDBusNewConnection(DBusServer *server, DBusConnection *connection, v // setPeer does the error handling for us QDBusErrorInternal error; newConnection->setPeer(connection, error); + newConnection->setDispatchEnabled(false); // this is a queued connection and will resume in the QDBusServer's thread emit serverConnection->newServerConnection(newConnection); + + // we've disabled dispatching of events, so now we post an event to the + // QDBusServer's thread in order to enable it after the + // QDBusServer::newConnection() signal has been received by the + // application's code + newConnection->ref.ref(); + QReadLocker serverLock(&serverConnection->lock); + QDBusConnectionDispatchEnabler *o = new QDBusConnectionDispatchEnabler(newConnection); + QTimer::singleShot(0, o, SLOT(execute())); + if (serverConnection->serverObject) + o->moveToThread(serverConnection->serverObject->thread()); } void QDBusConnectionPrivate::_q_newConnection(QDBusConnectionPrivate *newConnection) |