Merge lp:~3v1n0/unity/volume-imp-filemanager-crash-fix into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 3273
Proposed branch: lp:~3v1n0/unity/volume-imp-filemanager-crash-fix
Merge into: lp:unity
Diff against target: 115 lines (+39/-13)
5 files modified
launcher/TrashLauncherIcon.cpp (+6/-3)
launcher/TrashLauncherIcon.h (+1/-0)
launcher/VolumeImp.cpp (+13/-10)
tests/test_trash_launcher_icon.cpp (+11/-0)
tests/test_volume_imp.cpp (+8/-0)
To merge this branch: bzr merge lp:~3v1n0/unity/volume-imp-filemanager-crash-fix
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Andrea Azzarone (community) Approve
Review via email: mp+156969@code.launchpad.net

Commit message

Trash and Device Icons: disconnect from FileManager signal on destruction

Description of the change

Disconnect from file-manager signal when TrashLauncherIcon or VolumeImp are deleted (this is done using sigc::mem_fun with a sigc::trackable object).

Tests added.

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) wrote :

LGTM.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/TrashLauncherIcon.cpp'
2--- launcher/TrashLauncherIcon.cpp 2013-03-29 17:44:37 +0000
3+++ launcher/TrashLauncherIcon.cpp 2013-04-03 20:48:24 +0000
4@@ -69,13 +69,16 @@
5 });
6 }
7
8- file_manager_->locations_changed.connect([this] {
9- SetQuirk(Quirk::RUNNING, file_manager_->IsTrashOpened());
10- });
11+ file_manager_->locations_changed.connect(sigc::mem_fun(this, &TrashLauncherIcon::OnOpenedLocationsChanged));
12
13 UpdateTrashIcon();
14 }
15
16+void TrashLauncherIcon::OnOpenedLocationsChanged()
17+{
18+ SetQuirk(Quirk::RUNNING, file_manager_->IsTrashOpened());
19+}
20+
21 AbstractLauncherIcon::MenuItemsVector TrashLauncherIcon::GetMenus()
22 {
23 MenuItemsVector result;
24
25=== modified file 'launcher/TrashLauncherIcon.h'
26--- launcher/TrashLauncherIcon.h 2013-03-29 17:44:37 +0000
27+++ launcher/TrashLauncherIcon.h 2013-04-03 20:48:24 +0000
28@@ -49,6 +49,7 @@
29
30 private:
31 void ActivateLauncherIcon(ActionArg arg);
32+ void OnOpenedLocationsChanged();
33 MenuItemsVector GetMenus();
34
35 static void UpdateTrashIconCb(GObject* source, GAsyncResult* res, gpointer data);
36
37=== modified file 'launcher/VolumeImp.cpp'
38--- launcher/VolumeImp.cpp 2013-03-28 11:33:26 +0000
39+++ launcher/VolumeImp.cpp 2013-04-03 20:48:24 +0000
40@@ -32,7 +32,7 @@
41 // Start private implementation
42 //
43
44-class VolumeImp::Impl
45+class VolumeImp::Impl : public sigc::trackable
46 {
47 public:
48 Impl(glib::Object<GVolume> const& volume,
49@@ -54,15 +54,18 @@
50 parent_->removed.emit();
51 });
52
53- file_manager_->locations_changed.connect([this] {
54- bool opened = file_manager_->IsPrefixOpened(GetUri());
55-
56- if (opened_ != opened)
57- {
58- opened_ = opened;
59- parent_->opened.emit(opened_);
60- }
61- });
62+ file_manager_->locations_changed.connect(sigc::mem_fun(this, &Impl::OnLocationChanged));
63+ }
64+
65+ void OnLocationChanged()
66+ {
67+ bool opened = file_manager_->IsPrefixOpened(GetUri());
68+
69+ if (opened_ != opened)
70+ {
71+ opened_ = opened;
72+ parent_->opened.emit(opened_);
73+ }
74 }
75
76 bool CanBeEjected() const
77
78=== modified file 'tests/test_trash_launcher_icon.cpp'
79--- tests/test_trash_launcher_icon.cpp 2013-03-29 17:54:52 +0000
80+++ tests/test_trash_launcher_icon.cpp 2013-04-03 20:48:24 +0000
81@@ -82,4 +82,15 @@
82 EXPECT_FALSE(icon.GetQuirk(AbstractLauncherIcon::Quirk::RUNNING));
83 }
84
85+TEST_F(TestTrashLauncherIcon, FilemanagerSignalDisconnection)
86+{
87+ auto file_manager = std::make_shared<NiceMock<MockFileManager>>();
88+ {
89+ TrashLauncherIcon trash_icon(file_manager);
90+ ASSERT_FALSE(file_manager->locations_changed.empty());
91+ }
92+
93+ EXPECT_TRUE(file_manager->locations_changed.empty());
94+}
95+
96 }
97
98=== modified file 'tests/test_volume_imp.cpp'
99--- tests/test_volume_imp.cpp 2013-03-28 11:33:26 +0000
100+++ tests/test_volume_imp.cpp 2013-04-03 20:48:24 +0000
101@@ -140,6 +140,14 @@
102 EXPECT_TRUE(opened);
103 }
104
105+TEST_F(TestVolumeImp, TestFilemanagerSignalDisconnection)
106+{
107+ ASSERT_FALSE(file_manager_->locations_changed.empty());
108+ volume_.reset();
109+
110+ EXPECT_TRUE(file_manager_->locations_changed.empty());
111+}
112+
113 TEST_F(TestVolumeImp, TestEjectAndShowNotification)
114 {
115 g_mock_volume_set_can_eject(gvolume_, TRUE);