summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2010-09-21 10:55:22 -0400
committerOwen W. Taylor <otaylor@fishsoup.net>2010-09-30 10:47:40 -0400
commitf0473a63dca1eb6ad9dbf8f18370ebf7ed296a64 (patch)
tree31abecea8f3a0010d45593d109eab45aec2f8188
parentc8de0d2683dc5a5953b4c6e15c0357546a48985b (diff)
downloadgjs-f0473a63dca1eb6ad9dbf8f18370ebf7ed296a64.tar.gz
Use separate SetPrototype() and SetParent calls
In XULRunner 1.9.3, passing a custom prototype or parent to JS_ConstructObject for Object fails, so work around with a separate calls to SetPrototype()/SetParent(). See https://bugzilla.mozilla.org/show_bug.cgi?id=599651. https://bugzilla.gnome.org/show_bug.cgi?id=622896
-rw-r--r--gi/enumeration.c8
-rw-r--r--gi/repo.c5
-rw-r--r--gjs/importer.c8
-rw-r--r--modules/dbus.c9
4 files changed, 24 insertions, 6 deletions
diff --git a/gi/enumeration.c b/gi/enumeration.c
index 329b3a72..34f9e367 100644
--- a/gi/enumeration.c
+++ b/gi/enumeration.c
@@ -137,11 +137,15 @@ gjs_define_enumeration(JSContext *context,
return JS_TRUE;
}
- enum_obj = JS_ConstructObject(context, NULL, NULL,
- gjs_get_import_global(context));
+ enum_obj = JS_ConstructObject(context, NULL, NULL, NULL);
if (enum_obj == NULL)
return JS_FALSE;
+ /* https://bugzilla.mozilla.org/show_bug.cgi?id=599651 means we
+ * can't just pass in the global as the parent */
+ JS_SetParent(context, enum_obj,
+ gjs_get_import_global (context));
+
/* Fill in enum values first, so we don't define the enum itself until we're
* sure we can finish successfully.
*/
diff --git a/gi/repo.c b/gi/repo.c
index 7efd9f43..803238d8 100644
--- a/gi/repo.c
+++ b/gi/repo.c
@@ -283,7 +283,10 @@ repo_new(JSContext *context)
return JS_FALSE;
}
- versions = JS_ConstructObject(context, NULL, NULL, global);
+ versions = JS_ConstructObject(context, NULL, NULL, NULL);
+ /* https://bugzilla.mozilla.org/show_bug.cgi?id=599651 means we
+ * can't just pass in the global as the parent */
+ JS_SetParent(context, versions, global);
JS_DefineProperty(context, repo,
"versions",
diff --git a/gjs/importer.c b/gjs/importer.c
index 5265e934..0c6f6f39 100644
--- a/gjs/importer.c
+++ b/gjs/importer.c
@@ -285,12 +285,16 @@ load_module_init(JSContext *context,
}
}
- module_obj = JS_NewObject(context, NULL, NULL,
- gjs_get_import_global(context));
+ module_obj = JS_NewObject(context, NULL, NULL, NULL);
if (module_obj == NULL) {
return JS_FALSE;
}
+ /* https://bugzilla.mozilla.org/show_bug.cgi?id=599651 means we
+ * can't just pass in the global as the parent */
+ JS_SetParent(context, module_obj,
+ gjs_get_import_global (context));
+
/* Define module in importer for future use and to avoid module_obj
* object to be garbage collected during the evaluation of the script */
JS_DefineProperty(context, in_object,
diff --git a/modules/dbus.c b/modules/dbus.c
index 0222ab3e..eade473e 100644
--- a/modules/dbus.c
+++ b/modules/dbus.c
@@ -1750,9 +1750,16 @@ define_bus_object(JSContext *context,
bus_val = JSVAL_VOID;
JS_AddValueRoot(context, &bus_val);
- bus_obj = JS_ConstructObject(context, NULL, proto_obj, NULL);
+ bus_obj = JS_ConstructObject(context, NULL, NULL, NULL);
if (bus_obj == NULL)
goto out;
+ /* We need to use a separate call to SetPrototype to work
+ * around a SpiderMonkey bug where with clasp=NULL, the
+ * parent and proto arguments to JS_ConstructObject are
+ * lost.
+ * https://bugzilla.mozilla.org/show_bug.cgi?id=599651
+ */
+ JS_SetPrototype(context, bus_obj, proto_obj);
bus_val = OBJECT_TO_JSVAL(bus_obj);