Merge lp:~azzar1/libunity/fix-1506744 into lp:libunity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: 324
Merged at revision: 323
Proposed branch: lp:~azzar1/libunity/fix-1506744
Merge into: lp:libunity
Diff against target: 84 lines (+37/-17)
1 file modified
src/unity-appinfo-manager.vala (+37/-17)
To merge this branch: bzr merge lp:~azzar1/libunity/fix-1506744
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Marco Trevisan (Treviño) Approve
Review via email: mp+294855@code.launchpad.net

Commit message

Process GFileMonitors signals with a small timeout.

Description of the change

Process GFileMonitors signals with a small timeout. Please note that https://bugs.launchpad.net/ubuntu/+source/libunity/+bug/1506744/comments/42 is also required.

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

Good one, thanks

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/unity-appinfo-manager.vala'
--- src/unity-appinfo-manager.vala 2014-02-03 17:22:39 +0000
+++ src/unity-appinfo-manager.vala 2016-05-16 23:13:54 +0000
@@ -62,13 +62,15 @@
62 private HashTable<string, StringArrayWrapper> categories_by_id; /* desktop id or path -> xdg cats */62 private HashTable<string, StringArrayWrapper> categories_by_id; /* desktop id or path -> xdg cats */
63 private HashTable<string, StringArrayWrapper> keywords_by_id; /* desktop id or path -> X-GNOME-Keywords and X-AppInstall-Keywords */63 private HashTable<string, StringArrayWrapper> keywords_by_id; /* desktop id or path -> X-GNOME-Keywords and X-AppInstall-Keywords */
64 private HashTable<string,string?> paths_by_id; /* desktop id -> full path to desktop file */64 private HashTable<string,string?> paths_by_id; /* desktop id -> full path to desktop file */
65 65 private List<uint> timeout_handlers;
66
66 private AppInfoManager ()67 private AppInfoManager ()
67 {68 {
68 appinfo_by_id = new HashTable<string,AppInfo?> (str_hash, str_equal);69 appinfo_by_id = new HashTable<string,AppInfo?> (str_hash, str_equal);
69 categories_by_id = new HashTable<string,StringArrayWrapper> (str_hash, str_equal);70 categories_by_id = new HashTable<string,StringArrayWrapper> (str_hash, str_equal);
70 keywords_by_id = new HashTable<string,StringArrayWrapper> (str_hash, str_equal);71 keywords_by_id = new HashTable<string,StringArrayWrapper> (str_hash, str_equal);
71 paths_by_id = new HashTable<string,string?> (str_hash, str_equal);72 paths_by_id = new HashTable<string,string?> (str_hash, str_equal);
73 timeout_handlers = new List<uint> ();
7274
73 monitors = new HashTable<string,FileMonitor> (str_hash, str_equal);75 monitors = new HashTable<string,FileMonitor> (str_hash, str_equal);
74 76
@@ -86,7 +88,15 @@
86 }88 }
87 }89 }
88 }90 }
89 91
92 ~AppInfoManager ()
93 {
94 timeout_handlers.foreach ((id) =>
95 {
96 Source.remove (id);
97 });
98 }
99
90 [Deprecated (replacement = "AppInfoManager.get_default")]100 [Deprecated (replacement = "AppInfoManager.get_default")]
91 public static AppInfoManager get_instance ()101 public static AppInfoManager get_instance ()
92 {102 {
@@ -114,21 +124,31 @@
114 * we remove it from the cache */124 * we remove it from the cache */
115 private void on_dir_changed (FileMonitor mon, File file, File? other_file, FileMonitorEvent e)125 private void on_dir_changed (FileMonitor mon, File file, File? other_file, FileMonitorEvent e)
116 {126 {
117 var desktop_id = file.get_basename ();127 uint timeout_handler = 0;
118 var path = file.get_path ();128
119 AppInfo? appinfo;129 timeout_handler = Timeout.add_seconds (2, () =>
120 130 {
121 if (appinfo_by_id.remove (desktop_id))131 var desktop_id = file.get_basename ();
122 {132 var path = file.get_path ();
123 appinfo = lookup (desktop_id);133 AppInfo? appinfo;
124 changed (desktop_id, appinfo);134
125 }135 if (appinfo_by_id.remove (desktop_id))
126 136 {
127 if (appinfo_by_id.remove (path))137 appinfo = lookup (desktop_id);
128 {138 changed (desktop_id, appinfo);
129 appinfo = lookup (path);139 }
130 changed (path, appinfo);140
131 }141 if (appinfo_by_id.remove (path))
142 {
143 appinfo = lookup (path);
144 changed (path, appinfo);
145 }
146
147 timeout_handlers.remove (timeout_handler);
148 return false;
149 });
150
151 timeout_handlers.append (timeout_handler);
132 }152 }
133 153
134 /**154 /**

Subscribers

People subscribed via source and target branches