Merge lp:~mitya57/appmenu-qt5/lp1574699 into lp:appmenu-qt5

Proposed by Dmitry Shachnev on 2016-05-11
Status: Merged
Merged at revision: 41
Proposed branch: lp:~mitya57/appmenu-qt5/lp1574699
Merge into: lp:appmenu-qt5
Diff against target: 52 lines (+7/-7)
2 files modified
src/appmenuplatformsystemtrayicon.cpp (+6/-7)
src/appmenuplatformsystemtrayicon.h (+1/-0)
To merge this branch: bzr merge lp:~mitya57/appmenu-qt5/lp1574699
Reviewer Review Type Date Requested Status
Timo Jyrinki 2016-06-17 Pending
Sebastien Bacher 2016-06-17 Pending
ogoffart 2016-05-11 Pending
Łukasz Zemczak 2016-05-11 Pending
Indicator Applet Developers 2016-05-11 Pending
Review via email: mp+294381@code.launchpad.net

Commit Message

Fix for creating two or more system tray icons.

Description of the Change

This fixes creating multiple system tray icons.

To achieve this, separate connections are used for every icon.

To post a comment you must log in.
Dmitry Shachnev (mitya57) wrote :

Tested with:

* The test example from bug 1574699 (makes it working)
* The test example from QTBUG-53021 (makes it working)
* The systray example from qtbase5-examples (no regression)

Dmitry Shachnev (mitya57) wrote :

Note: I hope we'll get rid of appmenu-qt5 in Yakkety, but this fix is important for Xenial users.

Dmitry Shachnev (mitya57) wrote :

Ping? Łukasz, Olivier, can you please review this?

Dmitry Shachnev (mitya57) wrote :

I have tested it again on a clean system with three programs:

* Test app which creates two different tray icons with menus and submenus;
* The systray example from qtbase5-examples;
* Owncloud-client 2.1.1+dfsg-1ubuntu1 which does not have the workaround.

It works fine so I took the liberty to upload it to yakkety. If nobody complains, I will upload it to Xenial too in a couple of weeks.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/appmenuplatformsystemtrayicon.cpp'
2--- src/appmenuplatformsystemtrayicon.cpp 2015-06-29 18:47:54 +0000
3+++ src/appmenuplatformsystemtrayicon.cpp 2016-05-11 14:57:10 +0000
4@@ -41,22 +41,21 @@
5 AppMenuPlatformSystemTrayIcon::AppMenuPlatformSystemTrayIcon():
6 m_serviceName(KDEItemFormat.arg(QCoreApplication::applicationPid()).arg(++instanceCount)),
7 m_objectPath("/StatusNotifierItem"),
8+ m_connection(QDBusConnection::connectToBus(QDBusConnection::SessionBus, m_serviceName)),
9 m_sniAdaptor(new StatusNotifierItemAdaptor(this)),
10 m_dbusMenuExporter(Q_NULLPTR)
11 {
12 registerMetaTypes();
13- QDBusConnection bus = QDBusConnection::sessionBus();
14- bus.registerService(m_serviceName);
15- bus.registerObject(m_objectPath, this, QDBusConnection::ExportAdaptors);
16+ m_connection.registerService(m_serviceName);
17+ m_connection.registerObject(m_objectPath, this, QDBusConnection::ExportAdaptors);
18 QDBusInterface snw(SNW_SERVICE, SNW_PATH, SNW_INTERFACE);
19 snw.asyncCall("RegisterStatusNotifierItem", m_serviceName);
20 }
21
22 AppMenuPlatformSystemTrayIcon::~AppMenuPlatformSystemTrayIcon()
23 {
24- QDBusConnection bus = QDBusConnection::sessionBus();
25- bus.unregisterObject(m_objectPath, QDBusConnection::UnregisterTree);
26- bus.unregisterService(m_serviceName);
27+ m_connection.unregisterObject(m_objectPath, QDBusConnection::UnregisterTree);
28+ m_connection.unregisterService(m_serviceName);
29 delete m_sniAdaptor;
30 }
31
32@@ -91,7 +90,7 @@
33 {
34 QMenu *qMenu = qobject_cast<AppMenuPlatformMenu *>(menu)->m_menu;
35 QString menuObjectPath = m_objectPath + QStringLiteral("/menu");
36- m_dbusMenuExporter = new DBusMenuExporter(menuObjectPath, qMenu);
37+ m_dbusMenuExporter = new DBusMenuExporter(menuObjectPath, qMenu, m_connection);
38 }
39
40 QRect AppMenuPlatformSystemTrayIcon::geometry() const
41
42=== modified file 'src/appmenuplatformsystemtrayicon.h'
43--- src/appmenuplatformsystemtrayicon.h 2015-06-29 18:47:54 +0000
44+++ src/appmenuplatformsystemtrayicon.h 2016-05-11 14:57:10 +0000
45@@ -95,6 +95,7 @@
46 QIcon m_icon;
47 QString m_tooltip;
48
49+ QDBusConnection m_connection;
50 StatusNotifierItemAdaptor *m_sniAdaptor;
51 DBusMenuExporter *m_dbusMenuExporter;
52 };

Subscribers

People subscribed via source and target branches