diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2014-12-29 18:01:39 -0200 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2015-09-15 02:08:38 +0000 |
commit | 42858a9e88db6006ab541f3077f033415386400d (patch) | |
tree | 2d86a482bde5aff5dec14310a34cb05bd66c41a2 /src/dbus/qdbusintegrator.cpp | |
parent | c2049f67e4cfe5f09e1b033b910cb37d043a287e (diff) |
Simplify some code in QDBusConnectionPrivate::sendWithReplyAsync
They're pretty much the same, clearly a copy & paste. Instead, merge the
two codepaths so that we don't run the risk of applying a change in one
part and forgetting the other.
Task-number: QTBUG-43585
Change-Id: Ic5d393bfd36e48a193fcffff13b737560f6753be
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 | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 6e37ea6f7c..e87ae5b29d 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -2038,34 +2038,15 @@ QDBusPendingCallPrivate *QDBusConnectionPrivate::sendWithReplyAsync(const QDBusM QObject *receiver, const char *returnMethod, const char *errorMethod, int timeout) { - if (isServiceRegisteredByThread(message.service())) { + checkThread(); + + QDBusPendingCallPrivate *pcall = new QDBusPendingCallPrivate(message, this); + bool isLoopback; + if ((isLoopback = isServiceRegisteredByThread(message.service()))) { // special case for local calls - QDBusPendingCallPrivate *pcall = new QDBusPendingCallPrivate(message, this); pcall->replyMessage = sendWithReplyLocal(message); - if (receiver && returnMethod) - pcall->setReplyCallback(receiver, returnMethod); - - if (errorMethod) { - pcall->watcherHelper = new QDBusPendingCallWatcherHelper; - connect(pcall->watcherHelper, SIGNAL(error(QDBusError,QDBusMessage)), receiver, errorMethod, - Qt::QueuedConnection); - pcall->watcherHelper->moveToThread(thread()); - } - - if ((receiver && returnMethod) || errorMethod) { - // no one waiting, will delete pcall in processFinishedCall() - pcall->ref.store(1); - } else { - // set double ref to prevent race between processFinishedCall() and ref counting - // by QDBusPendingCall::QExplicitlySharedDataPointer<QDBusPendingCallPrivate> - pcall->ref.store(2); - } - processFinishedCall(pcall); - return pcall; } - checkThread(); - QDBusPendingCallPrivate *pcall = new QDBusPendingCallPrivate(message, this); if (receiver && returnMethod) pcall->setReplyCallback(receiver, returnMethod); @@ -2085,6 +2066,12 @@ QDBusPendingCallPrivate *QDBusConnectionPrivate::sendWithReplyAsync(const QDBusM pcall->ref.store(2); } + if (isLoopback) { + // a loopback call + processFinishedCall(pcall); + return pcall; + } + QDBusError error; DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, capabilities, &error); if (!msg) { |