Merge lp:~unity-api-team/hud/dbusmenu-safety-valve into lp:hud/14.04

Proposed by Pete Woods
Status: Merged
Approved by: Pete Woods
Approved revision: no longer in the source branch.
Merged at revision: 387
Proposed branch: lp:~unity-api-team/hud/dbusmenu-safety-valve
Merge into: lp:hud/14.04
Prerequisite: lp:~unity-api-team/hud/unix-signal-handler
Diff against target: 86 lines (+24/-8)
2 files modified
service/DBusMenuCollector.cpp (+22/-6)
service/DBusMenuCollector.h (+2/-2)
To merge this branch: bzr merge lp:~unity-api-team/hud/dbusmenu-safety-valve
Reviewer Review Type Date Requested Status
Marcus Tomlinson (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Albert Astals Cid Pending
Review via email: mp+212668@code.launchpad.net

Commit message

Add safety valve for DBusMenuCollector that also reports the offending application

Description of the change

Add safety valve for DBusMenuCollector that also reports the offending application

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
Marcus Tomlinson (marcustomlinson) wrote :

Bit ugly, but it works +1

review: Approve
387. By Pete Woods

Add safety valve for DBusMenuCollector that also reports the offending application Fixes: 1280372

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'service/DBusMenuCollector.cpp'
2--- service/DBusMenuCollector.cpp 2014-03-17 17:50:58 +0000
3+++ service/DBusMenuCollector.cpp 2014-03-26 09:00:34 +0000
4@@ -89,11 +89,17 @@
5 return hash;
6 }
7
8-void DBusMenuCollector::openMenu(QMenu *menu) {
9+void DBusMenuCollector::openMenu(QMenu *menu, unsigned int &limit) {
10 if (!menu) {
11 return;
12 }
13
14+ if (limit == 0) {
15+ qWarning() << "Hit DBusMenu safety valve for menu at" << m_service
16+ << m_path.path();
17+ return;
18+ }
19+
20 menu->aboutToShow();
21
22 for (int i(0); m_menuImporter && i < menu->actions().size(); ++i) {
23@@ -107,17 +113,25 @@
24
25 QMenu *child(action->menu());
26 if (child) {
27- openMenu(child);
28+ --limit;
29+ openMenu(child, limit);
30 }
31 }
32 }
33
34-void DBusMenuCollector::hideMenu(QMenu *menu) {
35+void DBusMenuCollector::hideMenu(QMenu *menu, unsigned int &limit) {
36+ if (limit == 0) {
37+ qWarning() << "Hit DBusMenu safety valve for menu at" << m_service
38+ << m_path.path();
39+ return;
40+ }
41+
42 for (int i(0); i < menu->actions().size(); ++i) {
43 QAction *action = menu->actions().at(i);
44 QMenu *child(action->menu());
45 if (child) {
46- hideMenu(child);
47+ --limit;
48+ hideMenu(child, limit);
49 }
50 }
51
52@@ -136,7 +150,8 @@
53 }
54
55 if (collectorToken.isNull()) {
56- openMenu(m_menuImporter->menu());
57+ unsigned int limit(50);
58+ openMenu(m_menuImporter->menu(), limit);
59
60 if(m_menuImporter.isNull()) {
61 return QList<CollectorToken::Ptr>();
62@@ -154,7 +169,8 @@
63 if(m_menuImporter.isNull()) {
64 return;
65 }
66- hideMenu(m_menuImporter->menu());
67+ unsigned int limit(50);
68+ hideMenu(m_menuImporter->menu(), limit);
69 }
70
71 void DBusMenuCollector::WindowRegistered(uint windowId, const QString &service,
72
73=== modified file 'service/DBusMenuCollector.h'
74--- service/DBusMenuCollector.h 2014-03-17 17:50:58 +0000
75+++ service/DBusMenuCollector.h 2014-03-26 09:00:34 +0000
76@@ -60,9 +60,9 @@
77 const QDBusObjectPath &menuObjectPath);
78
79 protected:
80- void openMenu(QMenu *menu);
81+ void openMenu(QMenu *menu, unsigned int &limit);
82
83- void hideMenu(QMenu *menu);
84+ void hideMenu(QMenu *menu, unsigned int &limit);
85
86 unsigned int m_windowId;
87

Subscribers

People subscribed via source and target branches