GNOME Bugzilla – Bug 626682
attempting to wrap a new GObject mid-construction blows up
Last modified: 2018-01-27 11:44:32 UTC
In gi/object.c:object_instance_constructor, if you did a "new Foo()" in JS where Foo is a GObject, we do: priv->gobj = g_object_newv(gtype, n_params, params); Unfortunately, g_object_newv can/will emit signals on other objects, such as those passed in as "params". If one of these signals has the new Foo as an argument, we try to wrap the Foo instance which ends up recursively calling object_instance_constructor on the new Foo. This assertion then fails: g_assert(peek_js_obj(context, priv->gobj) == NULL); because g_object_newv already wrapped the object we were constructing with another JS object, instead of the JS object that we were constructing. An example of when this would happen is if two objects refer to each other (say a widget points to its parent container and vice versa) and you set the parent at construct time which sets the child of the container, *and* someone has hooked up a JS callback that watches new children of the container, then the JS callback needs to wrap the child that we just constructed. new Child({ parent: myContainer }) blows up if JS connected to myContainer would see the new child, since that JS will need a wrapper for the new child GObject inside of g_object_new. I have no idea how to fix this without making a huge mess of the code. (For example, we could keep a stack of object_instance_constructor in progress and try to handle the case that way, but ...)
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gjs/issues/50.