seed r263 - trunk/libseed
- From: racarr svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r263 - trunk/libseed
- Date: Wed, 12 Nov 2008 14:03:19 +0000 (UTC)
Author: racarr
Date: Wed Nov 12 14:03:19 2008
New Revision: 263
URL: http://svn.gnome.org/viewvc/seed?rev=263&view=rev
Log:
Make sure that if unref ressurects a GObject (in say, cycle case between container->child), the "js-ref" data on the object does not point to a finalized wrapper.
Modified:
trunk/libseed/seed-engine.c
trunk/libseed/seed-types.c
Modified: trunk/libseed/seed-engine.c
==============================================================================
--- trunk/libseed/seed-engine.c (original)
+++ trunk/libseed/seed-engine.c Wed Nov 12 14:03:19 2008
@@ -138,15 +138,12 @@
gobject = g_object_newv(type, nparams, params);
- if (g_object_is_floating(gobject))
- g_object_ref_sink(gobject);
- else if (gobject->ref_count == 0)
- g_object_ref(gobject);
+ g_object_ref_sink (gobject);
if (!gobject)
ret = (JSObjectRef)JSValueMakeNull(eng->context);
-
- ret = (JSObjectRef)seed_value_from_object(gobject, exception);
+ else
+ ret = (JSObjectRef)seed_value_from_object(gobject, exception);
g_object_unref(gobject);
@@ -509,6 +506,8 @@
gobject = seed_value_to_object((JSValueRef) object, 0);
if (!gobject)
return;
+
+ g_object_set_data_full (gobject, "js-ref", NULL, NULL);
g_object_remove_toggle_ref(gobject, seed_toggle_ref, 0);
g_object_unref(gobject);
Modified: trunk/libseed/seed-types.c
==============================================================================
--- trunk/libseed/seed-types.c (original)
+++ trunk/libseed/seed-types.c Wed Nov 12 14:03:19 2008
@@ -56,6 +56,12 @@
}
+static void seed_gobject_destroyed(gpointer object)
+{
+ JSValueUnprotect(eng->context, (JSValueRef)object);
+ JSObjectSetPrivate((JSObjectRef)object, 0);
+}
+
static JSValueRef seed_wrap_object(GObject * object)
{
JSValueRef user_data;
@@ -88,7 +94,8 @@
g_assert_not_reached();
}
- g_object_set_data(object, "js-ref", (gpointer) js_ref);
+ g_object_set_data_full(object, "js-ref", (gpointer) js_ref,
+ seed_gobject_destroyed);
JSValueProtect(eng->context, js_ref);
g_object_add_toggle_ref(object, seed_toggle_ref, (gpointer) js_ref);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]