Merge lp:~stolowski/libunity/fix-module-open into lp:libunity

Proposed by Paweł Stołowski
Status: Merged
Approved by: Michal Hruby
Approved revision: 291
Merged at revision: 290
Proposed branch: lp:~stolowski/libunity/fix-module-open
Merge into: lp:libunity
Diff against target: 46 lines (+9/-9)
1 file modified
src/unity-scope-loader.vala (+9/-9)
To merge this branch: bzr merge lp:~stolowski/libunity/fix-module-open
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+184574@code.launchpad.net

Commit message

Check actual return value of GLib.Module.open to avoid assertion errors and fail early rather than on get_version check later.

Description of the change

Check actual return value of GLib.Module.open to avoid assertion errors and fail early rather than on get_version check later.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
291. By Paweł Stołowski

Changed variable name. Report error details when Module.open fails.

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

Better error reporting is always great ;)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/unity-scope-loader.vala'
2--- src/unity-scope-loader.vala 2013-08-06 08:09:15 +0000
3+++ src/unity-scope-loader.vala 2013-09-09 13:56:25 +0000
4@@ -36,33 +36,33 @@
5 {
6 }
7
8- public virtual List<Unity.AbstractScope> get_scopes (string module, string? module_type) throws Error
9+ public virtual List<Unity.AbstractScope> get_scopes (string module_name, string? module_type) throws Error
10 {
11- var mod = GLib.Module.open (module, ModuleFlags.BIND_LAZY);
12+ var module = GLib.Module.open (module_name, ModuleFlags.BIND_LAZY);
13 if (module == null)
14 {
15- throw new GLib.IOError.FAILED (@"Could not load module '$module'");
16+ throw new GLib.IOError.FAILED ("Could not load module '%s': %s", module_name, GLib.Module.error());
17 }
18
19 void *function;
20- if (!mod.symbol ("unity_scope_module_get_version", out function))
21+ if (!module.symbol ("unity_scope_module_get_version", out function))
22 {
23- throw new GLib.IOError.FAILED (@"Could not find 'get_version' symbol in '$module'");
24+ throw new GLib.IOError.FAILED (@"Could not find 'get_version' symbol in '$module_name'");
25 }
26 var get_version = (GetVersionFunction)function;
27 if (get_version () != Unity.SCOPE_API_VERSION)
28 {
29- throw new GLib.IOError.FAILED (@"Plugin '$module' is for wrong Scope API version");
30+ throw new GLib.IOError.FAILED (@"Plugin '$module_name' is for wrong Scope API version");
31 }
32
33- if (!mod.symbol ("unity_scope_module_load_scopes", out function))
34+ if (!module.symbol ("unity_scope_module_load_scopes", out function))
35 {
36- throw new GLib.IOError.FAILED (@"Could not find 'load_scopes' symbol in '$module'");
37+ throw new GLib.IOError.FAILED (@"Could not find 'load_scopes' symbol in '$module_name'");
38 }
39
40 // Since we're executing code within the module at this point, it
41 // should not be unloaded.
42- mod.make_resident ();
43+ module.make_resident ();
44 var load_scopes = (LoadScopesFunction)function;
45 return load_scopes ();
46 }

Subscribers

People subscribed via source and target branches