Merge lp:~osomon/unity-2d/launcher-client-really-async into lp:unity-2d/3.0

Proposed by Olivier Tilloy
Status: Merged
Approved by: Florian Boucault
Approved revision: 474
Merged at revision: 475
Proposed branch: lp:~osomon/unity-2d/launcher-client-really-async
Merge into: lp:unity-2d/3.0
Diff against target: 74 lines (+13/-24)
1 file modified
libunity-2d-private/src/launcherclient.cpp (+13/-24)
To merge this branch: bzr merge lp:~osomon/unity-2d/launcher-client-really-async
Reviewer Review Type Date Requested Status
Bill Filler (community) Approve
Review via email: mp+54379@code.launchpad.net

Commit message

[launcher] Make calls to the launcher’s DBus interface in the LauncherClient really asynchronous.

To post a comment you must log in.
Revision history for this message
Bill Filler (bfiller) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libunity-2d-private/src/launcherclient.cpp'
2--- libunity-2d-private/src/launcherclient.cpp 2011-03-22 11:30:53 +0000
3+++ libunity-2d-private/src/launcherclient.cpp 2011-03-22 16:35:19 +0000
4@@ -21,11 +21,9 @@
5 // Self
6 #include "launcherclient.h"
7
8-// Local
9-#include <debug_p.h>
10-
11 // Qt
12-#include <QDBusInterface>
13+#include <QDBusConnection>
14+#include <QDBusMessage>
15 #include <QDBusPendingCall>
16
17 static const char* LAUNCHER_DBUS_SERVICE = "com.canonical.Unity2d.Launcher";
18@@ -38,22 +36,16 @@
19 {
20 LauncherClient* q;
21
22- QDBusInterface* m_iface;
23- bool init()
24+ void asyncDBusCall(const QString& methodName)
25 {
26- if (m_iface) {
27- return true;
28- }
29-
30- m_iface = new QDBusInterface(LAUNCHER_DBUS_SERVICE, LAUNCHER_DBUS_OBJECT_PATH, LAUNCHER_DBUS_INTERFACE,
31- QDBusConnection::sessionBus(), q);
32- if (!m_iface->isValid()) {
33- UQ_WARNING << "Could not connect to Launcher on DBus";
34- delete m_iface;
35- m_iface = 0;
36- return false;
37- }
38- return true;
39+ /* The constructor for QDBusInterface potentially does synchronous
40+ introspection calls. In contrast, this is really asynchronous.
41+ See rationale at https://bugs.launchpad.net/unity-2d/+bug/738025. */
42+ QDBusMessage call = QDBusMessage::createMethodCall(LAUNCHER_DBUS_SERVICE,
43+ LAUNCHER_DBUS_OBJECT_PATH,
44+ LAUNCHER_DBUS_INTERFACE,
45+ methodName);
46+ QDBusConnection::sessionBus().asyncCall(call);
47 }
48 };
49
50@@ -62,7 +54,6 @@
51 , d(new LauncherClientPrivate)
52 {
53 d->q = this;
54- d->m_iface = 0;
55 }
56
57 LauncherClient::~LauncherClient()
58@@ -72,14 +63,12 @@
59
60 void LauncherClient::beginForceVisible()
61 {
62- UQ_RETURN_IF_FAIL(d->init());
63- d->m_iface->asyncCall("BeginForceVisible");
64+ d->asyncDBusCall("BeginForceVisible");
65 }
66
67 void LauncherClient::endForceVisible()
68 {
69- UQ_RETURN_IF_FAIL(d->init());
70- d->m_iface->asyncCall("EndForceVisible");
71+ d->asyncDBusCall("EndForceVisible");
72 }
73
74 #include "launcherclient.moc"

Subscribers

People subscribed via source and target branches