[seed] Fix some more context confusion, and add a seed_prepare_global_context function



commit e84377143afd804aa0643db9f3c3060f317ca911
Author: Robert Carr <racarr mireia (none)>
Date:   Mon Apr 13 16:49:20 2009 -0400

    Fix some more context confusion, and add a seed_prepare_global_context function
---
 examples/browser/BrowserView.js |    4 ++++
 libseed/seed-importer.c         |   12 ++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/examples/browser/BrowserView.js b/examples/browser/BrowserView.js
index 0e9e705..1037702 100644
--- a/examples/browser/BrowserView.js
+++ b/examples/browser/BrowserView.js
@@ -2,6 +2,10 @@ Gtk = imports.gi.Gtk;
 WebKit = imports.gi.WebKit;
 
 Seed.print("In BrowserView.js imports: " + imports);
+Seed.print("imports.gi: " + imports.gi);
+Seed.print("imports.gi.WebKit: " + imports.gi.WebKit);
+
+Seed.quit();
 
 BrowserView = new GType({
     parent: WebKit.WebView.type,
diff --git a/libseed/seed-importer.c b/libseed/seed-importer.c
index 7f2b40c..2551d0f 100644
--- a/libseed/seed-importer.c
+++ b/libseed/seed-importer.c
@@ -327,8 +327,10 @@ seed_gi_importer_do_namespace (JSContextRef ctx,
   g_free (version);
   
   n = g_irepository_get_n_infos (NULL, namespace);
-  namespace_ref = JSObjectMake (ctx, NULL, NULL);
-  JSValueProtect (ctx, namespace_ref);
+  
+  namespace_ref = JSObjectMake (eng->context, NULL, NULL);
+
+  JSValueProtect (eng->context, namespace_ref);
   
   for (i = 0; i < n; i++)
     {
@@ -368,6 +370,9 @@ seed_gi_importer_do_namespace (JSContextRef ctx,
     }
   
   g_hash_table_insert (gi_imports, g_strdup(namespace), namespace_ref);
+  
+  // Protect with respect to our persistent context. 
+  // TODO: Investigate whether this is correct.
 
   jsextension = g_strdup_printf ("imports.extensions.%s",
 				namespace);
@@ -544,6 +549,9 @@ seed_importer_handle_file (JSContextRef ctx,
   nctx = JSGlobalContextCreateInGroup (context_group, 0);
   seed_prepare_global_context (nctx);
   
+  global = JSContextGetGlobalObject (nctx);
+  JSValueProtect (eng->context, global);
+  
   JSEvaluateScript (nctx, file_contents, NULL, file_name, 0, exception);
 
   g_hash_table_insert (file_imports, file_path, global);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]