diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2014-12-29 19:47:54 -0200 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2015-09-15 02:08:43 +0000 |
commit | 5d41a4aa5a3324a2326142300da3b853bb14b070 (patch) | |
tree | 22a1ad6757498b7875f7329bca4c1cc030216f94 /src/dbus | |
parent | df7064c1514c66610c56487e0444036539aa8645 (diff) |
And move the sending of other types of D-Bus messages to the thread
With this, we now know that all messages sent are sent from the same
thread. This simplifies greatly the handling of the socket.
Task-number: QTBUG-43585
Change-Id: Ic5d393bfd36e48a193fcffff13b73758087344ed
Reviewed-by: Albert Astals Cid <aacid@kde.org>
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/dbus')
-rw-r--r-- | src/dbus/qdbusconnection_p.h | 2 | ||||
-rw-r--r-- | src/dbus/qdbusintegrator.cpp | 23 | ||||
-rw-r--r-- | src/dbus/qdbusthreaddebug_p.h | 2 |
3 files changed, 15 insertions, 12 deletions
diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index 3becc7cbc3..f653c427e7 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -272,7 +272,7 @@ private slots: signals: void dispatchStatusChanged(); - void messageNeedsSending(QDBusPendingCallPrivate *pcall, void *msg, int timeout); + void messageNeedsSending(QDBusPendingCallPrivate *pcall, void *msg, int timeout = -1); void serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner); void callWithCallbackFailed(const QDBusError &error, const QDBusMessage &message); void newServerConnection(QDBusConnectionPrivate *newConnection); diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 77f27e6fb1..d5eaf39021 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1874,13 +1874,9 @@ bool QDBusConnectionPrivate::send(const QDBusMessage& message) } q_dbus_message_set_no_reply(msg, true); // the reply would not be delivered to anything - qDBusDebug() << this << "sending message (no reply):" << message; - checkThread(); - QDBusDispatchLocker locker(SendMessageAction, this); - bool isOk = q_dbus_connection_send(connection, msg, 0); - q_dbus_message_unref(msg); - return isOk; + emit messageNeedsSending(Q_NULLPTR, msg); + return true; } // small helper to note long running blocking dbus calls. @@ -2089,10 +2085,15 @@ void QDBusConnectionPrivate::sendInternal(QDBusPendingCallPrivate *pcall, void * QDBusError error; DBusPendingCall *pending = 0; DBusMessage *msg = static_cast<DBusMessage *>(message); + bool isNoReply = !pcall; + Q_ASSERT(isNoReply == !!q_dbus_message_get_no_reply(msg)); + checkThread(); + QDBusDispatchLocker locker(SendMessageAction, this); - QDBusDispatchLocker locker(SendWithReplyAsyncAction, this); - if (q_dbus_connection_send_with_reply(connection, msg, &pending, timeout)) { + if (isNoReply && q_dbus_connection_send(connection, msg, Q_NULLPTR)) { + // success + } else if (!isNoReply && q_dbus_connection_send_with_reply(connection, msg, &pending, timeout)) { if (pending) { q_dbus_message_unref(msg); @@ -2113,8 +2114,10 @@ void QDBusConnectionPrivate::sendInternal(QDBusPendingCallPrivate *pcall, void * } q_dbus_message_unref(msg); - pcall->replyMessage = QDBusMessage::createError(error); - processFinishedCall(pcall); + if (pcall) { + pcall->replyMessage = QDBusMessage::createError(error); + processFinishedCall(pcall); + } } bool QDBusConnectionPrivate::connectSignal(const QString &service, diff --git a/src/dbus/qdbusthreaddebug_p.h b/src/dbus/qdbusthreaddebug_p.h index 60b6acd38d..eace25478d 100644 --- a/src/dbus/qdbusthreaddebug_p.h +++ b/src/dbus/qdbusthreaddebug_p.h @@ -83,7 +83,7 @@ enum ThreadAction { HandleObjectCallPostEventAction = 22, HandleObjectCallSemaphoreAction = 23, DoDispatchAction = 24, - SendWithReplyAsyncAction = 25, + // unused: 25, MessageResultReceivedAction = 26, ActivateSignalAction = 27, PendingCallBlockAction = 28, |