[seed: 7/15] Protect against multiple imports
- From: Robert Carr <racarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [seed: 7/15] Protect against multiple imports
- Date: Sun, 12 Apr 2009 02:11:19 -0400 (EDT)
commit 8c714a8651697a258828c36e636c1b24d8245bc3
Author: Robert Carr <racarr mireia (none)>
Date: Sat Apr 11 18:31:34 2009 -0400
Protect against multiple imports
---
libseed/seed-importer.c | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/libseed/seed-importer.c b/libseed/seed-importer.c
index 2551756..7620c44 100644
--- a/libseed/seed-importer.c
+++ b/libseed/seed-importer.c
@@ -9,6 +9,8 @@ JSClassRef gi_importer_class;
JSObjectRef gi_importer;
JSObjectRef gi_importer_versions;
+GHashTable *gi_imports;
+
static void
seed_gi_importer_handle_function (JSContextRef ctx,
JSObjectRef namespace_ref,
@@ -252,8 +254,12 @@ seed_gi_importer_do_namespace (JSContextRef ctx,
GError *e = NULL;
guint n, i;
+ if (namespace_ref = g_hash_table_lookup (gi_imports, namespace))
+ {
+ return namespace_ref;
+ }
+
// TODO: Versions.
- // TODO: Guard against multiple imports.
if (!g_irepository_require (NULL, namespace,
NULL, 0, &e))
{
@@ -302,6 +308,8 @@ seed_gi_importer_do_namespace (JSContextRef ctx,
g_base_info_unref (info);
}
+ g_hash_table_insert (gi_imports, g_strdup(namespace), namespace_ref);
+
return namespace_ref;
}
@@ -399,5 +407,7 @@ void seed_initialize_importer(JSContextRef ctx,
gi_importer = JSObjectMake (ctx, gi_importer_class, NULL);
gi_importer_versions = JSObjectMake (ctx, gi_importer_class, NULL);
+ gi_imports = g_hash_table_new (g_str_hash, g_str_equal);
+
seed_object_set_property (ctx, global, "imports", importer);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]