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
=== modified file 'launcher/TrashLauncherIcon.cpp'
--- launcher/TrashLauncherIcon.cpp 2013-03-29 17:44:37 +0000
+++ launcher/TrashLauncherIcon.cpp 2013-04-03 20:48:24 +0000
@@ -69,13 +69,16 @@
69 });69 });
70 }70 }
7171
72 file_manager_->locations_changed.connect([this] {72 file_manager_->locations_changed.connect(sigc::mem_fun(this, &TrashLauncherIcon::OnOpenedLocationsChanged));
73 SetQuirk(Quirk::RUNNING, file_manager_->IsTrashOpened());
74 });
7573
76 UpdateTrashIcon();74 UpdateTrashIcon();
77}75}
7876
77void TrashLauncherIcon::OnOpenedLocationsChanged()
78{
79 SetQuirk(Quirk::RUNNING, file_manager_->IsTrashOpened());
80}
81
79AbstractLauncherIcon::MenuItemsVector TrashLauncherIcon::GetMenus()82AbstractLauncherIcon::MenuItemsVector TrashLauncherIcon::GetMenus()
80{83{
81 MenuItemsVector result;84 MenuItemsVector result;
8285
=== modified file 'launcher/TrashLauncherIcon.h'
--- launcher/TrashLauncherIcon.h 2013-03-29 17:44:37 +0000
+++ launcher/TrashLauncherIcon.h 2013-04-03 20:48:24 +0000
@@ -49,6 +49,7 @@
4949
50private:50private:
51 void ActivateLauncherIcon(ActionArg arg);51 void ActivateLauncherIcon(ActionArg arg);
52 void OnOpenedLocationsChanged();
52 MenuItemsVector GetMenus();53 MenuItemsVector GetMenus();
5354
54 static void UpdateTrashIconCb(GObject* source, GAsyncResult* res, gpointer data);55 static void UpdateTrashIconCb(GObject* source, GAsyncResult* res, gpointer data);
5556
=== modified file 'launcher/VolumeImp.cpp'
--- launcher/VolumeImp.cpp 2013-03-28 11:33:26 +0000
+++ launcher/VolumeImp.cpp 2013-04-03 20:48:24 +0000
@@ -32,7 +32,7 @@
32// Start private implementation32// Start private implementation
33//33//
3434
35class VolumeImp::Impl35class VolumeImp::Impl : public sigc::trackable
36{36{
37public:37public:
38 Impl(glib::Object<GVolume> const& volume,38 Impl(glib::Object<GVolume> const& volume,
@@ -54,15 +54,18 @@
54 parent_->removed.emit();54 parent_->removed.emit();
55 });55 });
5656
57 file_manager_->locations_changed.connect([this] {57 file_manager_->locations_changed.connect(sigc::mem_fun(this, &Impl::OnLocationChanged));
58 bool opened = file_manager_->IsPrefixOpened(GetUri());58 }
5959
60 if (opened_ != opened)60 void OnLocationChanged()
61 {61 {
62 opened_ = opened;62 bool opened = file_manager_->IsPrefixOpened(GetUri());
63 parent_->opened.emit(opened_);63
64 }64 if (opened_ != opened)
65 });65 {
66 opened_ = opened;
67 parent_->opened.emit(opened_);
68 }
66 }69 }
6770
68 bool CanBeEjected() const71 bool CanBeEjected() const
6972
=== modified file 'tests/test_trash_launcher_icon.cpp'
--- tests/test_trash_launcher_icon.cpp 2013-03-29 17:54:52 +0000
+++ tests/test_trash_launcher_icon.cpp 2013-04-03 20:48:24 +0000
@@ -82,4 +82,15 @@
82 EXPECT_FALSE(icon.GetQuirk(AbstractLauncherIcon::Quirk::RUNNING));82 EXPECT_FALSE(icon.GetQuirk(AbstractLauncherIcon::Quirk::RUNNING));
83}83}
8484
85TEST_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
85}96}
8697
=== modified file 'tests/test_volume_imp.cpp'
--- tests/test_volume_imp.cpp 2013-03-28 11:33:26 +0000
+++ tests/test_volume_imp.cpp 2013-04-03 20:48:24 +0000
@@ -140,6 +140,14 @@
140 EXPECT_TRUE(opened);140 EXPECT_TRUE(opened);
141}141}
142142
143TEST_F(TestVolumeImp, TestFilemanagerSignalDisconnection)
144{
145 ASSERT_FALSE(file_manager_->locations_changed.empty());
146 volume_.reset();
147
148 EXPECT_TRUE(file_manager_->locations_changed.empty());
149}
150
143TEST_F(TestVolumeImp, TestEjectAndShowNotification)151TEST_F(TestVolumeImp, TestEjectAndShowNotification)
144{152{
145 g_mock_volume_set_can_eject(gvolume_, TRUE);153 g_mock_volume_set_can_eject(gvolume_, TRUE);