Merge lp:~aacid/unity-2d/cache_spread_shown into lp:unity-2d

Proposed by Albert Astals Cid
Status: Merged
Approved by: Paweł Stołowski
Approved revision: 1027
Merged at revision: 1027
Proposed branch: lp:~aacid/unity-2d/cache_spread_shown
Merge into: lp:unity-2d
Diff against target: 85 lines (+32/-5)
3 files modified
libunity-2d-private/src/spreadmonitor.cpp (+19/-5)
libunity-2d-private/src/spreadmonitor.h (+8/-0)
tests/manual-tests/launcher.txt (+5/-0)
To merge this branch: bzr merge lp:~aacid/unity-2d/cache_spread_shown
Reviewer Review Type Date Requested Status
Paweł Stołowski (community) Approve
Review via email: mp+100371@code.launchpad.net

Commit message

Use a internal cache for the spread shown value

Otherwise when the service becomes available it may happen that we do
the shownChanged(true) because it's shown and the shownChanged(true) because of
the direct connection between signals and thus the shell ends up with
two shownChanged(true) and forces the visibiity of the launcher twice, meaning
that if we are using hide-mode 1 the launcher will be stuck shown forever

Description of the change

Use a internal cache for the spread shown value

Otherwise when the service becomes available it may happen that we do
the shownChanged(true) because it's shown and the shownChanged(true) because of
the direct connection between signals and thus the shell ends up with
two shownChanged(true) and forces the visibiity of the launcher twice, meaning
that if we are using hide-mode 1 the launcher will be stuck shown forever

To post a comment you must log in.
Revision history for this message
Paweł Stołowski (stolowski) wrote :

Great finding!

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/spreadmonitor.cpp'
2--- libunity-2d-private/src/spreadmonitor.cpp 2012-02-09 11:38:44 +0000
3+++ libunity-2d-private/src/spreadmonitor.cpp 2012-04-02 08:28:21 +0000
4@@ -28,7 +28,8 @@
5
6 SpreadMonitor::SpreadMonitor(QObject *parent)
7 : AbstractDBusServiceMonitor("com.canonical.Unity2d.Spread", "/Spread",
8- "com.canonical.Unity2d.Spread", parent)
9+ "com.canonical.Unity2d.Spread", parent),
10+ m_shown(false)
11 {
12 connect(this, SIGNAL(serviceAvailableChanged(bool)), SLOT(onServiceAvailableChanged(bool)));
13
14@@ -40,22 +41,35 @@
15 void SpreadMonitor::onServiceAvailableChanged(bool available)
16 {
17 if (available) {
18- connect(dbusInterface(), SIGNAL(IsShownChanged(bool)), SIGNAL(shownChanged(bool)));
19+ connect(dbusInterface(), SIGNAL(IsShownChanged(bool)), SLOT(internalSetShown(bool)));
20
21 /* In SpreadMonitor::shown() we assume shown is false if the service is not
22 available therefore there is no need to emit shownChanged if it is still false */
23- if (shown()) {
24- Q_EMIT shownChanged(true);
25+ if (dbusShown()) {
26+ internalSetShown(true);
27 }
28 } else {
29 /* At this point we cannot know for sure that the spread was shown so
30 we emit the changed signal unconditionally */
31- Q_EMIT shownChanged(false);
32+ internalSetShown(false);
33 }
34 }
35
36 bool SpreadMonitor::shown() const
37 {
38+ return m_shown;
39+}
40+
41+void SpreadMonitor::internalSetShown(bool shown)
42+{
43+ if (shown != m_shown) {
44+ m_shown = shown;
45+ Q_EMIT shownChanged(m_shown);
46+ }
47+}
48+
49+bool SpreadMonitor::dbusShown() const
50+{
51 if (dbusInterface() == 0) {
52 return false;
53 } else {
54
55=== modified file 'libunity-2d-private/src/spreadmonitor.h'
56--- libunity-2d-private/src/spreadmonitor.h 2012-02-08 15:12:09 +0000
57+++ libunity-2d-private/src/spreadmonitor.h 2012-04-02 08:28:21 +0000
58@@ -41,6 +41,14 @@
59
60 Q_SIGNALS:
61 void shownChanged(bool visible);
62+
63+private Q_SLOTS:
64+ void internalSetShown(bool shown);
65+
66+private:
67+ bool dbusShown() const;
68+
69+ bool m_shown;
70 };
71
72 Q_DECLARE_METATYPE(SpreadMonitor*)
73
74=== modified file 'tests/manual-tests/launcher.txt'
75--- tests/manual-tests/launcher.txt 2012-03-28 10:43:57 +0000
76+++ tests/manual-tests/launcher.txt 2012-04-02 08:28:21 +0000
77@@ -115,3 +115,8 @@
78
79 Verify that the shell starts without problems (does not segfault) (Do it multiple times since there's the odd time it works)
80 ----
81+
82+ * Use hide-mode 1. killall both unity-2d-shell and unity-2d-spread. Start only the shell. Click twice on the launcher spread icon. Move the mouse away from the launcher
83+
84+Verify that the launcher hides correctly
85+----

Subscribers

People subscribed via source and target branches