Merge lp:~pete-woods/libdbusmenu-qt/sync-mode-option into lp:libdbusmenu-qt

Proposed by Pete Woods
Status: Merged
Approved by: Antti Kaijanmäki
Approved revision: 263
Merged at revision: 263
Proposed branch: lp:~pete-woods/libdbusmenu-qt/sync-mode-option
Merge into: lp:libdbusmenu-qt
Diff against target: 188 lines (+77/-37)
3 files modified
debian/changelog (+13/-0)
src/dbusmenuimporter.cpp (+48/-37)
src/dbusmenuimporter.h (+16/-0)
To merge this branch: bzr merge lp:~pete-woods/libdbusmenu-qt/sync-mode-option
Reviewer Review Type Date Requested Status
Antti Kaijanmäki (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Marcus Tomlinson Pending
Review via email: mp+209445@code.launchpad.net

Commit message

Add option to make DBus calls synchronous

Description of the change

* Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
  * Yes
 * Did you build your software in a clean sbuild/pbuilder chroot or ppa?
  * Yes
 * Did you build your software in a clean sbuild/pbuilder armhf chroot or ppa?
  * Yes
 * Has your component "TestPlan” been executed successfully on emulator, N4?
  * Yes
 * Has a 5 minute exploratory testing run been executed on N4?
  * Yes
 * If you changed the packaging (debian), did you subscribe a core-dev to this MP?
  * N/A
 * If you changed the UI, did you subscribe the design-reviewers to this MP?
  * No change
 * What components might get impacted by your changes?
  * Unity HUD
 * Have you requested review by the teams of these owning components?
  * Yes

Check List:
https://wiki.ubuntu.com/Process/Merges/Checklists/libdbusmenu-qt

Test Plan:
https://wiki.ubuntu.com/Process/Merges/TestPlan/libdbusmenu-qt

Silo:
https://launchpad.net/~ci-train-ppa-service/+archive/landing-002/

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

LGTM. Waiting for silo.

Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

 * Are any changes against your component pending/needed to land the MP under review in a functional state and are those called out explicitly by the submitter?
YES.

 * Did you do exploratory testing related to the component you own with the MP changeset included?
YES.

 * Has the submitter requested review by all the relevant teams/reviewres?
YES.

 * If you are the reviewer owning the component the MP is against, have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?
YES.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2014-02-18 14:33:02 +0000
+++ debian/changelog 2014-03-14 14:12:57 +0000
@@ -1,3 +1,16 @@
1libdbusmenu-qt (0.9.3-0ubuntu1) UNRELEASED; urgency=medium
2
3 [ Pete Woods ]
4 * Add importer parameter to allow control over DBus behavior.
5
6 -- Pete Woods <pete.woods@canonical.com> Wed, 05 Mar 2014 09:36:46 +0000
7
8libdbusmenu-qt (0.9.2+14.04.20140305-0ubuntu1) trusty; urgency=low
9
10 * New rebuild forced
11
12 -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Wed, 05 Mar 2014 09:29:14 +0000
13
1libdbusmenu-qt (0.9.2+14.04.20140218.2-0ubuntu1) trusty; urgency=low14libdbusmenu-qt (0.9.2+14.04.20140218.2-0ubuntu1) trusty; urgency=low
215
3 [ Pete Woods ]16 [ Pete Woods ]
417
=== modified file 'src/dbusmenuimporter.cpp'
--- src/dbusmenuimporter.cpp 2014-02-18 11:52:15 +0000
+++ src/dbusmenuimporter.cpp 2014-03-14 14:12:57 +0000
@@ -89,6 +89,8 @@
8989
90 bool m_mustEmitMenuUpdated;90 bool m_mustEmitMenuUpdated;
9191
92 DBusMenuImporterType m_type;
93
92 QDBusPendingCallWatcher *refresh(int id)94 QDBusPendingCallWatcher *refresh(int id)
93 {95 {
94 #ifdef BENCHMARK96 #ifdef BENCHMARK
@@ -279,9 +281,51 @@
279 QVariant empty = QVariant::fromValue(QDBusVariant(QString()));281 QVariant empty = QVariant::fromValue(QDBusVariant(QString()));
280 m_interface->asyncCall("Event", id, eventId, empty, 0u);282 m_interface->asyncCall("Event", id, eventId, empty, 0u);
281 }283 }
284
285 bool waitForWatcher(QDBusPendingCallWatcher * _watcher, int maxWait)
286 {
287 QPointer<QDBusPendingCallWatcher> watcher(_watcher);
288
289 if(m_type == ASYNCHRONOUS) {
290 QTimer timer;
291 timer.setSingleShot(true);
292 QEventLoop loop;
293 loop.connect(&timer, SIGNAL(timeout()), SLOT(quit()));
294 loop.connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher *)), SLOT(quit()));
295 timer.start(maxWait);
296 loop.exec();
297 timer.stop();
298
299 if (!watcher) {
300 // Watcher died. This can happen if importer got deleted while we were
301 // waiting. See:
302 // https://bugs.kde.org/show_bug.cgi?id=237156
303 return false;
304 }
305
306 if(!watcher->isFinished()) {
307 // Timed out
308 return false;
309 }
310 } else {
311 watcher->waitForFinished();
312 }
313
314 if (watcher->isError()) {
315 DMWARNING << watcher->error().message();
316 return false;
317 }
318
319 return true;
320 }
282};321};
283322
284DBusMenuImporter::DBusMenuImporter(const QString &service, const QString &path, QObject *parent)323DBusMenuImporter::DBusMenuImporter(const QString &service, const QString &path, QObject *parent)
324: DBusMenuImporter(service, path, ASYNCHRONOUS, parent)
325{
326}
327
328DBusMenuImporter::DBusMenuImporter(const QString &service, const QString &path, DBusMenuImporterType type, QObject *parent)
285: QObject(parent)329: QObject(parent)
286, d(new DBusMenuImporterPrivate)330, d(new DBusMenuImporterPrivate)
287{331{
@@ -292,6 +336,8 @@
292 d->m_menu = 0;336 d->m_menu = 0;
293 d->m_mustEmitMenuUpdated = false;337 d->m_mustEmitMenuUpdated = false;
294338
339 d->m_type = type;
340
295 connect(&d->m_mapper, SIGNAL(mapped(int)), SLOT(sendClickedEvent(int)));341 connect(&d->m_mapper, SIGNAL(mapped(int)), SLOT(sendClickedEvent(int)));
296342
297 d->m_pendingLayoutUpdateTimer = new QTimer(this);343 d->m_pendingLayoutUpdateTimer = new QTimer(this);
@@ -443,41 +489,6 @@
443 QMetaObject::invokeMethod(menu(), "aboutToShow");489 QMetaObject::invokeMethod(menu(), "aboutToShow");
444}490}
445491
446static bool waitForWatcher(QDBusPendingCallWatcher * _watcher, int maxWait)
447{
448 QPointer<QDBusPendingCallWatcher> watcher(_watcher);
449
450 {
451 QTimer timer;
452 timer.setSingleShot(true);
453 QEventLoop loop;
454 loop.connect(&timer, SIGNAL(timeout()), SLOT(quit()));
455 loop.connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher *)), SLOT(quit()));
456 timer.start(maxWait);
457 loop.exec();
458 timer.stop();
459 }
460
461 if (!watcher) {
462 // Watcher died. This can happen if importer got deleted while we were
463 // waiting. See:
464 // https://bugs.kde.org/show_bug.cgi?id=237156
465 return false;
466 }
467
468 if(!watcher->isFinished()) {
469 // Timed out
470 return false;
471 }
472
473 if (watcher->isError()) {
474 DMWARNING << watcher->error().message();
475 return false;
476 }
477
478 return true;
479}
480
481void DBusMenuImporter::slotMenuAboutToShow()492void DBusMenuImporter::slotMenuAboutToShow()
482{493{
483 QMenu *menu = qobject_cast<QMenu*>(sender());494 QMenu *menu = qobject_cast<QMenu*>(sender());
@@ -501,7 +512,7 @@
501512
502 QPointer<QObject> guard(this);513 QPointer<QObject> guard(this);
503514
504 if (!waitForWatcher(watcher, ABOUT_TO_SHOW_TIMEOUT)) {515 if (!d->waitForWatcher(watcher, ABOUT_TO_SHOW_TIMEOUT)) {
505 DMWARNING << "Application did not answer to AboutToShow() before timeout";516 DMWARNING << "Application did not answer to AboutToShow() before timeout";
506 }517 }
507518
@@ -541,7 +552,7 @@
541 if (needRefresh || menu->actions().isEmpty()) {552 if (needRefresh || menu->actions().isEmpty()) {
542 d->m_idsRefreshedByAboutToShow << id;553 d->m_idsRefreshedByAboutToShow << id;
543 watcher = d->refresh(id);554 watcher = d->refresh(id);
544 if (!waitForWatcher(watcher, REFRESH_TIMEOUT)) {555 if (!d->waitForWatcher(watcher, REFRESH_TIMEOUT)) {
545 DMWARNING << "Application did not refresh before timeout";556 DMWARNING << "Application did not refresh before timeout";
546 }557 }
547 }558 }
548559
=== modified file 'src/dbusmenuimporter.h'
--- src/dbusmenuimporter.h 2013-12-18 09:29:06 +0000
+++ src/dbusmenuimporter.h 2014-03-14 14:12:57 +0000
@@ -35,6 +35,16 @@
35class QMenu;35class QMenu;
3636
37class DBusMenuImporterPrivate;37class DBusMenuImporterPrivate;
38
39/**
40 * Determine whether internal method calls should allow the Qt event loop
41 * to execute or not
42 */
43enum DBusMenuImporterType {
44 ASYNCHRONOUS,
45 SYNCHRONOUS
46};
47
38/**48/**
39 * A DBusMenuImporter instance can recreate a menu serialized over DBus by49 * A DBusMenuImporter instance can recreate a menu serialized over DBus by
40 * DBusMenuExporter50 * DBusMenuExporter
@@ -48,6 +58,12 @@
48 */58 */
49 DBusMenuImporter(const QString &service, const QString &path, QObject *parent = 0);59 DBusMenuImporter(const QString &service, const QString &path, QObject *parent = 0);
5060
61 /**
62 * Creates a DBusMenuImporter listening over DBus on service, path, with either async
63 * or sync DBus calls
64 */
65 DBusMenuImporter(const QString &service, const QString &path, DBusMenuImporterType type, QObject *parent = 0);
66
51 virtual ~DBusMenuImporter();67 virtual ~DBusMenuImporter();
5268
53 /**69 /**

Subscribers

People subscribed via source and target branches

to all changes: