Merge lp:~mhr3/unity-lens-applications/improve-error-handling into lp:unity-lens-applications

Proposed by Michal Hruby
Status: Merged
Approved by: Paweł Stołowski
Approved revision: 350
Merged at revision: 348
Proposed branch: lp:~mhr3/unity-lens-applications/improve-error-handling
Merge into: lp:unity-lens-applications
Diff against target: 228 lines (+90/-48)
5 files modified
src/app-watcher.vala (+25/-18)
src/daemon.vala (+55/-27)
src/main.vala (+1/-1)
src/runner.vala (+8/-1)
src/utils.vala (+1/-1)
To merge this branch: bzr merge lp:~mhr3/unity-lens-applications/improve-error-handling
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Paweł Stołowski (community) Approve
Review via email: mp+172312@code.launchpad.net

Commit message

Improve error handling, which can cause the scope searches to lock up.

Description of the change

Improve error handling, which can cause the scope searches to lock up.

To post a comment you must log in.
Revision history for this message
Paweł Stołowski (stolowski) wrote :

67 + catch (Error err)
68 + {
69 + critical ("Unable to export scope: %s", err.message);
70 + }

I think inability to export scope should result in a fatal and stop the process, there's not point in keeping it running. Or it's not the case?

review: Needs Information
Revision history for this message
Michal Hruby (mhr3) wrote :

> 67 + catch (Error err)
> 68 + {
> 69 + critical ("Unable to export scope: %s", err.message);
> 70 + }
>
> I think inability to export scope should result in a fatal and stop the
> process, there's not point in keeping it running. Or it's not the case?

And that's why it's a critical and not a warning :)

350. By Michal Hruby

Abort when scope can't be exported

Revision history for this message
Paweł Stołowski (stolowski) wrote :

Looks fine now. +1

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app-watcher.vala'
2--- src/app-watcher.vala 2012-01-18 17:02:52 +0000
3+++ src/app-watcher.vala 2013-07-01 12:18:28 +0000
4@@ -51,24 +51,31 @@
5 Path.DIR_SEPARATOR_S, null);
6 }
7
8- var connection = Bus.get_sync (BusType.SESSION);
9- connection.signal_subscribe ("org.ayatana.bamf",
10- "org.ayatana.bamf.matcher",
11- "RunningApplicationsChanged",
12- "/org/ayatana/bamf/matcher",
13- null,
14- DBusSignalFlags.NONE,
15- this.running_apps_changed);
16- connection.call.begin ("org.ayatana.bamf",
17- "/org/ayatana/bamf/matcher",
18- "org.ayatana.bamf.matcher",
19- "RunningApplicationsDesktopFiles",
20- null,
21- null,
22- 0,
23- -1,
24- null,
25- this.got_running_apps);
26+ try
27+ {
28+ var connection = Bus.get_sync (BusType.SESSION);
29+ connection.signal_subscribe ("org.ayatana.bamf",
30+ "org.ayatana.bamf.matcher",
31+ "RunningApplicationsChanged",
32+ "/org/ayatana/bamf/matcher",
33+ null,
34+ DBusSignalFlags.NONE,
35+ this.running_apps_changed);
36+ connection.call.begin ("org.ayatana.bamf",
37+ "/org/ayatana/bamf/matcher",
38+ "org.ayatana.bamf.matcher",
39+ "RunningApplicationsDesktopFiles",
40+ null,
41+ null,
42+ 0,
43+ -1,
44+ null,
45+ this.got_running_apps);
46+ }
47+ catch (Error err)
48+ {
49+ warning ("Unable to get running applications: %s", err.message);
50+ }
51 }
52
53 private void got_running_apps (Object? src_obj,
54
55=== modified file 'src/daemon.vala'
56--- src/daemon.vala 2013-06-20 13:11:17 +0000
57+++ src/daemon.vala 2013-07-01 12:18:28 +0000
58@@ -235,7 +235,14 @@
59 aptdclient = new AptdProxy ();
60 launcherservice = new LauncherProxy ();
61
62- scope.export ();
63+ try
64+ {
65+ scope.export ();
66+ }
67+ catch (Error err)
68+ {
69+ error ("Unable to export scope: %s", err.message);
70+ }
71
72 remote_scopes_model = new Dee.SharedModel ("com.canonical.Unity.SmartScopes.RemoteScopesModel");
73 remote_scopes_model.set_schema ("s", "s", "s", "s", "s", "as");
74@@ -285,21 +292,26 @@
75 SearchType search_type,
76 GLib.Cancellable cancellable)
77 {
78- if (popularities_dirty)
79- {
80- popularities_dirty = false;
81- // we're not passing the cancellable, cause cancelling this search
82- // shouldn't cancel getting most popular apps
83- yield update_popularities ();
84- if (cancellable.is_cancelled ()) return;
85- }
86-
87- if (search_type == SearchType.DEFAULT)
88- yield update_scope_search (search, cancellable);
89- else
90- yield update_global_search (search, cancellable);
91-
92- search.finished ();
93+ try
94+ {
95+ if (popularities_dirty)
96+ {
97+ popularities_dirty = false;
98+ // we're not passing the cancellable, cause cancelling this search
99+ // shouldn't cancel getting most popular apps
100+ yield update_popularities ();
101+ if (cancellable.is_cancelled ()) return;
102+ }
103+
104+ if (search_type == SearchType.DEFAULT)
105+ yield update_scope_search (search, cancellable);
106+ else
107+ yield update_global_search (search, cancellable);
108+ }
109+ finally
110+ {
111+ search.finished ();
112+ }
113 }
114
115 private void populate_categories ()
116@@ -438,11 +450,18 @@
117
118 private async void build_scope_index ()
119 {
120- var scope_registry = yield Unity.Protocol.ScopeRegistry.find_scopes (
121- Config.PKGDATADIR + "/scopes");
122+ try
123+ {
124+ var scope_registry = yield Unity.Protocol.ScopeRegistry.find_scopes (
125+ Config.PKGDATADIR + "/scopes");
126
127- debug ("Indexing scopes");
128- scopesearcher = new Unity.Package.Searcher.for_scopes (scope_registry);
129+ debug ("Indexing scopes");
130+ scopesearcher = new Unity.Package.Searcher.for_scopes (scope_registry);
131+ }
132+ catch (Error err)
133+ {
134+ warning ("Unable to find scopes: %s", err.message);
135+ }
136 }
137
138 private void populate_zg_templates ()
139@@ -598,7 +617,15 @@
140 }
141 }
142
143- transaction.commit ();
144+ // FIXME: use the new API and ResultSet.flush () instead
145+ try
146+ {
147+ transaction.commit ();
148+ }
149+ catch (Error err)
150+ {
151+ warning ("Unable to commit transaction: %s", err.message);
152+ }
153
154 // add scopes (if filter is active)
155 if (!has_filter || type_filter.get_option ("scopes").active)
156@@ -974,12 +1001,13 @@
157 bool x_ubuntu_touch = false;
158 if (full_path != null)
159 {
160- GLib.KeyFile key_file = new GLib.KeyFile();
161- key_file.load_from_file(full_path, GLib.KeyFileFlags.NONE);
162- try {
163- x_ubuntu_touch = key_file.get_boolean("Desktop Entry", "X-Ubuntu-Touch");
164+ GLib.KeyFile key_file = new GLib.KeyFile ();
165+ try
166+ {
167+ key_file.load_from_file (full_path, GLib.KeyFileFlags.NONE);
168+ x_ubuntu_touch = key_file.get_boolean ("Desktop Entry", "X-Ubuntu-Touch");
169 }
170- catch (GLib.KeyFileError e)
171+ catch (Error e)
172 {
173 x_ubuntu_touch = false;
174 }
175@@ -1238,7 +1266,7 @@
176 launcherservice.connect_to_launcher ();
177 string desktop_file = preview_installable_desktop_file;
178 Icon icon = find_pkg_icon (null, preview_installable_icon_file);
179- launcherservice.add_launcher_item_from_position (appname, icon.to_string (), 0, 0, 32, desktop_file, tid);
180+ launcherservice.add_launcher_item_from_position.begin (appname, icon.to_string (), 0, 0, 32, desktop_file, tid);
181 }
182 catch (IOError e)
183 {
184
185=== modified file 'src/main.vala'
186--- src/main.vala 2013-05-16 11:37:05 +0000
187+++ src/main.vala 2013-07-01 12:18:28 +0000
188@@ -43,7 +43,7 @@
189 -1);
190 result.get ("(b)", out has_owner);
191 return has_owner;
192- } catch (IOError e) {
193+ } catch (Error e) {
194 warning ("Unable to decide whether '%s' is running: %s", name, e.message);
195 }
196
197
198=== modified file 'src/runner.vala'
199--- src/runner.vala 2013-06-11 11:08:47 +0000
200+++ src/runner.vala 2013-07-01 12:18:28 +0000
201@@ -90,7 +90,14 @@
202
203 this.daemon = daemon;
204
205- scope.export ();
206+ try
207+ {
208+ scope.export ();
209+ }
210+ catch (Error err)
211+ {
212+ error ("Unable to export scope: %s", err.message);
213+ }
214 }
215
216 private void populate_categories ()
217
218=== modified file 'src/utils.vala'
219--- src/utils.vala 2013-05-16 11:37:05 +0000
220+++ src/utils.vala 2013-07-01 12:18:28 +0000
221@@ -165,7 +165,7 @@
222 });
223 out_analyzer = analyzer;
224
225- var reader = Dee.ModelReader.new (reader_func);
226+ var reader = Dee.ModelReader.new ((owned) reader_func);
227 return new Dee.TreeIndex (filter_model, analyzer, reader);
228 }
229

Subscribers

People subscribed via source and target branches