GitLab repository storage has been migrated to hashed layout. Please contact Infrastructure team if you notice any issues with repositories or hooks.

object: properly disassociate wrappers

Now that we allow different JS wrappers during the lifetime of
a single GObject, the code must be extra careful to really
disassociate wrapper and wrapped objects.

The current code, however, was not really disassociating the
wrapper from the GObject it wraps, causing a segfault when
the first wrapper is destroyed and the second is created.
parent 0cc23474
Pipeline #9081 passed with stages
in 24 minutes and 18 seconds
......@@ -158,7 +158,7 @@ get_object_qdata(GObject *gobj)
auto priv = static_cast<ObjectInstance *>(g_object_get_qdata(gobj,
if (priv && G_UNLIKELY(priv->js_object_finalized)) {
if (priv && priv->uses_toggle_ref && G_UNLIKELY(priv->js_object_finalized)) {
g_critical("Object %p (a %s) resurfaced after the JS wrapper was finalized. "
"This is some library doing dubious memory management inside dispose()",
gobj, g_type_name(G_TYPE_FROM_INSTANCE(gobj)));
......@@ -1357,11 +1357,16 @@ disassociate_js_gobject(GObject *gobj)
gobj, G_OBJECT_TYPE_NAME(gobj));
/* Fist, remove the wrapper pointer from the wrapped GObject */
set_object_qdata(gobj, nullptr);
/* Now release all the resources the current wrapper has */
/* Mark that a JS object once existed, but it doesn't any more */
priv->js_object_finalized = true;
priv->keep_alive = nullptr;
static void
......@@ -1587,6 +1592,9 @@ object_instance_finalize(JSFreeOp *fop,
g_slice_free(ObjectInstance, priv);
/* Remove the ObjectInstance pointer from the JSObject */
JS_SetPrivate(obj, nullptr);
static JSObject *
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment