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
1=== modified file 'launcher/TrashLauncherIcon.cpp'
2--- launcher/TrashLauncherIcon.cpp 2015-12-11 15:15:47 +0000
3+++ launcher/TrashLauncherIcon.cpp 2016-07-13 18:14:25 +0000
4@@ -55,23 +55,27 @@
5 SkipQuirkAnimation(Quirk::VISIBLE);
6 SetShortcut('t');
7
8- glib::Object<GFile> location(g_file_new_for_uri(TRASH_URI.c_str()));
9-
10- glib::Error err;
11- trash_monitor_ = g_file_monitor_directory(location, G_FILE_MONITOR_NONE, cancellable_, &err);
12- g_file_monitor_set_rate_limit(trash_monitor_, 1000);
13-
14- if (err)
15- {
16- LOG_ERROR(logger) << "Could not create file monitor for trash uri: " << err;
17- }
18- else
19- {
20- glib_signals_.Add<void, GFileMonitor*, GFile*, GFile*, GFileMonitorEvent>(trash_monitor_, "changed",
21- [this] (GFileMonitor*, GFile*, GFile*, GFileMonitorEvent) {
22- UpdateTrashIcon();
23- });
24- }
25+ _source_manager.AddIdle([this]{
26+ glib::Object<GFile> location(g_file_new_for_uri(TRASH_URI.c_str()));
27+
28+ glib::Error err;
29+ trash_monitor_ = g_file_monitor_directory(location, G_FILE_MONITOR_NONE, cancellable_, &err);
30+ g_file_monitor_set_rate_limit(trash_monitor_, 1000);
31+
32+ if (err)
33+ {
34+ LOG_ERROR(logger) << "Could not create file monitor for trash uri: " << err;
35+ }
36+ else
37+ {
38+ glib_signals_.Add<void, GFileMonitor*, GFile*, GFile*, GFileMonitorEvent>(trash_monitor_, "changed",
39+ [this] (GFileMonitor*, GFile*, GFile*, GFileMonitorEvent) {
40+ UpdateTrashIcon();
41+ });
42+ }
43+
44+ return false;
45+ });
46
47 UpdateTrashIcon();
48 UpdateStorageWindows();