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/qdbusintegrator.cpp | |
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/qdbusintegrator.cpp')
-rw-r--r-- | src/dbus/qdbusintegrator.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
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, |