Merge lp:~azzar1/unity/fix-trash-li-blocking into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 4148
Proposed branch: lp:~azzar1/unity/fix-trash-li-blocking
Merge into: lp:unity
Diff against target: 48 lines (+21/-17)
1 file modified
launcher/TrashLauncherIcon.cpp (+21/-17)
To merge this branch: bzr merge lp:~azzar1/unity/fix-trash-li-blocking
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+299957@code.launchpad.net

Commit message

[TrashLauncherIcon] Create GFileMonitor in an idle to avoid blocking calls.

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

You can just use _source_manager from LauncherIcon.h (which is protected)

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Thanks

review: Approve

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 2015-12-11 15:15:47 +0000
+++ launcher/TrashLauncherIcon.cpp 2016-07-13 18:14:25 +0000
@@ -55,23 +55,27 @@
55 SkipQuirkAnimation(Quirk::VISIBLE);55 SkipQuirkAnimation(Quirk::VISIBLE);
56 SetShortcut('t');56 SetShortcut('t');
5757
58 glib::Object<GFile> location(g_file_new_for_uri(TRASH_URI.c_str()));58 _source_manager.AddIdle([this]{
5959 glib::Object<GFile> location(g_file_new_for_uri(TRASH_URI.c_str()));
60 glib::Error err;60
61 trash_monitor_ = g_file_monitor_directory(location, G_FILE_MONITOR_NONE, cancellable_, &err);61 glib::Error err;
62 g_file_monitor_set_rate_limit(trash_monitor_, 1000);62 trash_monitor_ = g_file_monitor_directory(location, G_FILE_MONITOR_NONE, cancellable_, &err);
6363 g_file_monitor_set_rate_limit(trash_monitor_, 1000);
64 if (err)64
65 {65 if (err)
66 LOG_ERROR(logger) << "Could not create file monitor for trash uri: " << err;66 {
67 }67 LOG_ERROR(logger) << "Could not create file monitor for trash uri: " << err;
68 else68 }
69 {69 else
70 glib_signals_.Add<void, GFileMonitor*, GFile*, GFile*, GFileMonitorEvent>(trash_monitor_, "changed",70 {
71 [this] (GFileMonitor*, GFile*, GFile*, GFileMonitorEvent) {71 glib_signals_.Add<void, GFileMonitor*, GFile*, GFile*, GFileMonitorEvent>(trash_monitor_, "changed",
72 UpdateTrashIcon();72 [this] (GFileMonitor*, GFile*, GFile*, GFileMonitorEvent) {
73 });73 UpdateTrashIcon();
74 }74 });
75 }
76
77 return false;
78 });
7579
76 UpdateTrashIcon();80 UpdateTrashIcon();
77 UpdateStorageWindows();81 UpdateStorageWindows();