summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu@centricular.com>2019-12-04 19:15:36 +0100
committerThibault Saunier <tsaunier@gnome.org>2021-12-06 22:19:49 +0000
commit6115565b13f13407021b9f0b4d92c8c890eb19d8 (patch)
tree91034891eaa10cdeebfd2cd0e53f890f7918183a
parent963c5f278e23d971a5bdf055c900b3ae156fbeb3 (diff)
downloadgobject-introspection-6115565b13f13407021b9f0b4d92c8c890eb19d8.tar.gz
gimodule: fix floating state of python objects created with g_object_new
If C code calls g_object_new() for a GInitiallyUnowned subclass implemented in python, the expectation is to receive a floating reference. The solution is used is the same picked for 5efe2e5c8458d9f4d72329ea1209d96b5ebecfb4, this is simply a special case that was omitted at the time.
-rw-r--r--gi/gimodule.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/gi/gimodule.c b/gi/gimodule.c
index 4668369c..02daba85 100644
--- a/gi/gimodule.c
+++ b/gi/gimodule.c
@@ -1087,9 +1087,18 @@ pygobject__g_instance_init(GTypeInstance *instance,
/* this looks like a python object created through
* g_object_new -> we have no python wrapper, so create it
* now */
- wrapper = pygobject_new_full(object,
- /*steal=*/ FALSE,
- g_class);
+
+ if (g_object_is_floating (object)) {
+ g_object_ref (object);
+ wrapper = pygobject_new_full(object,
+ /*steal=*/ TRUE,
+ g_class);
+ g_object_force_floating (object);
+ } else {
+ wrapper = pygobject_new_full(object,
+ /*steal=*/ FALSE,
+ g_class);
+ }
/* float the wrapper ref here because we are going to orphan it
* so we don't destroy the wrapper. The next call to pygobject_new_full