Merge lp:~thumper/unity/decaymulator-destructor into lp:unity

Proposed by Tim Penhey
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 2162
Proposed branch: lp:~thumper/unity/decaymulator-destructor
Merge into: lp:unity
Diff against target: 56 lines (+10/-4)
2 files modified
plugins/unityshell/src/Decaymulator.cpp (+8/-3)
plugins/unityshell/src/Decaymulator.h (+2/-1)
To merge this branch: bzr merge lp:~thumper/unity/decaymulator-destructor
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
Review via email: mp+98951@code.launchpad.net

Commit message

Make sure the decay function callback is removed on object destruction.

Description of the change

== The problem ==

Unity seg faults if you unplug a monitor while the pointer barrier is still decaying it's values.

== The solution ==

Add a destructor that removes the source if there is one.

== Tests ==

Not really easy to test. Not sure a manual test would help here.

UNBLOCK

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/Decaymulator.cpp'
2--- plugins/unityshell/src/Decaymulator.cpp 2012-01-26 03:41:33 +0000
3+++ plugins/unityshell/src/Decaymulator.cpp 2012-03-23 01:00:28 +0000
4@@ -21,13 +21,19 @@
5
6 namespace unity {
7 namespace ui {
8-
9+
10 Decaymulator::Decaymulator()
11 {
12 on_decay_handle = 0;
13 value.changed.connect(sigc::mem_fun(this, &Decaymulator::OnValueChanged));
14 }
15
16+Decaymulator::~Decaymulator()
17+{
18+ if (on_decay_handle)
19+ g_source_remove(on_decay_handle);
20+}
21+
22 void Decaymulator::OnValueChanged(int value)
23 {
24 if (!on_decay_handle && value > 0)
25@@ -49,10 +55,9 @@
26 return FALSE;
27 }
28
29-
30 self->value = self->value - partial_decay;
31 return TRUE;
32 }
33
34 }
35-}
36\ No newline at end of file
37+}
38
39=== modified file 'plugins/unityshell/src/Decaymulator.h'
40--- plugins/unityshell/src/Decaymulator.h 2012-01-26 03:41:33 +0000
41+++ plugins/unityshell/src/Decaymulator.h 2012-03-23 01:00:28 +0000
42@@ -37,6 +37,7 @@
43 nux::Property<int> value;
44
45 Decaymulator();
46+ ~Decaymulator();
47
48 private:
49 void OnValueChanged(int value);
50@@ -48,4 +49,4 @@
51 }
52 }
53
54-#endif
55\ No newline at end of file
56+#endif