summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Mazari <amazari@igalia.com>2011-08-31 10:49:01 (GMT)
committerAlan Knowles <alan@akbkhome.com>2011-09-01 04:20:34 (GMT)
commit6ae79c21436f036f36ab7ebfe1b5466ae741f00d (patch)
treea8d5a76437414288d13168e9f175beec475a7ea6
parenteedae3e24b470b28951b9d303b65b94ad9613209 (diff)
downloadseed-6ae79c21436f036f36ab7ebfe1b5466ae741f00d.tar.gz
seed-6ae79c21436f036f36ab7ebfe1b5466ae741f00d.tar.xz
Fix #657833 - Import GLib namespace when searchPath is initialized. GLib might have extension present in the searchPath. Also makes extension loading exceptions bubble up to the javascript context.
https://bugzilla.gnome.org/show_bug.cgi?id=657833
-rw-r--r--extensions/Seed.js.in73
-rw-r--r--libseed/seed-importer.c2
2 files changed, 37 insertions, 38 deletions
diff --git a/extensions/Seed.js.in b/extensions/Seed.js.in
index 9acb189..7f10e21 100644
--- a/extensions/Seed.js.in
+++ b/extensions/Seed.js.in
@@ -1,4 +1,39 @@
-GLib = imports.gi.GLib;
+if(!imports.searchPath || (imports.searchPath.length == 0))
+{
+ imports.searchPath = [ "%gnomejsdir%",
+ "%pkglibdir%",
+ "%pkgdatadir%",
+ "/usr/local/lib/seed",
+ "/usr/local/share/seed",
+ "/usr/lib/seed",
+ "/usr/share/seed" ];
+
+ GLib = imports.gi.GLib;
+ if(Seed.argv.length > 1)
+ {
+ __script_path__ = GLib.path_get_dirname(Seed.argv[1]);
+
+ try
+ {
+ if(!GLib.path_is_absolute(__script_path__))
+ {
+ __script_path__ = GLib.build_filenamev([GLib.get_current_dir(),
+ __script_path__]);
+ }
+
+ __script_path__ = imports.os.realpath(__script_path__);
+
+ if(__script_path__ && __script_path__ != "")
+ imports.searchPath.unshift(__script_path__);
+ }
+ catch(e)
+ {
+ print(imports.JSON.stringify(e));
+ }
+ }
+
+ imports.searchPath.unshift(".");
+}
Seed.sprintf = function ()
{
@@ -170,39 +205,3 @@ Seed.thread_repl = function()
}
Seed.printf = function () { print(Seed.sprintf.apply(this, arguments)) };
-
-if(!imports.searchPath || (imports.searchPath.length == 0))
-{
- imports.searchPath = [ "%gnomejsdir%",
- "%pkglibdir%",
- "%pkgdatadir%",
- "/usr/local/lib/seed",
- "/usr/local/share/seed",
- "/usr/lib/seed",
- "/usr/share/seed" ];
-
- if(Seed.argv.length > 1)
- {
- __script_path__ = GLib.path_get_dirname(Seed.argv[1]);
-
- try
- {
- if(!GLib.path_is_absolute(__script_path__))
- {
- __script_path__ = GLib.build_filenamev([GLib.get_current_dir(),
- __script_path__]);
- }
-
- __script_path__ = imports.os.realpath(__script_path__);
-
- if(__script_path__ && __script_path__ != "")
- imports.searchPath.unshift(__script_path__);
- }
- catch(e)
- {
- print(imports.JSON.stringify(e));
- }
- }
-
- imports.searchPath.unshift(".");
-}
diff --git a/libseed/seed-importer.c b/libseed/seed-importer.c
index 0c0caf9..a69bf8e 100644
--- a/libseed/seed-importer.c
+++ b/libseed/seed-importer.c
@@ -466,7 +466,7 @@ seed_gi_importer_do_namespace (JSContextRef ctx,
jsextension = g_strdup_printf ("imports.extensions.%s", namespace);
extension_script = JSStringCreateWithUTF8CString (jsextension);
- JSEvaluateScript (ctx, extension_script, NULL, NULL, 0, NULL);
+ JSEvaluateScript (ctx, extension_script, NULL, NULL, 0, exception);
JSStringRelease (extension_script);
g_free (jsextension);