[pygobject/pygobject-2-28: 1/4] Revert "Fix reference leaks for GInitiallyUnowned objects"
- From: Steve Frécinaux <sfre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject/pygobject-2-28: 1/4] Revert "Fix reference leaks for GInitiallyUnowned objects"
- Date: Wed, 9 Feb 2011 16:44:54 +0000 (UTC)
commit 4c9715b29f8883e23027cca10157ea96013b0dbc
Author: Steve Frécinaux <code istique net>
Date: Wed Feb 9 16:33:42 2011 +0100
Revert "Fix reference leaks for GInitiallyUnowned objects"
This reverts commit f0a0b6c2eda89622de2b1e5ebb6a48103ad72a42.
The test cases have been kept.
https://bugzilla.gnome.org/show_bug.cgi?id=641525
gobject/gobjectmodule.c | 2 --
gobject/pygobject.c | 14 +++++++-------
2 files changed, 7 insertions(+), 9 deletions(-)
---
diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c
index 4ca092d..acf94ce 100644
--- a/gobject/gobjectmodule.c
+++ b/gobject/gobjectmodule.c
@@ -1728,7 +1728,6 @@ pyg_object_new (PyGObject *self, PyObject *args, PyObject *kwargs)
g_type_class_unref(class);
if (obj) {
- pygobject_sink (obj);
self = (PyGObject *) pygobject_new_full((GObject *)obj, FALSE, NULL);
g_object_unref(obj);
} else
@@ -2228,7 +2227,6 @@ pygobject_constructv(PyGObject *self,
pygobject_init_wrapper_set((PyObject *) self);
obj = g_object_newv(pyg_type_from_object((PyObject *) self),
n_parameters, parameters);
- pygobject_sink (obj);
pygobject_init_wrapper_set(NULL);
if (self->obj == NULL) {
self->obj = obj;
diff --git a/gobject/pygobject.c b/gobject/pygobject.c
index 9be644a..face97a 100644
--- a/gobject/pygobject.c
+++ b/gobject/pygobject.c
@@ -146,13 +146,12 @@ pygobject_sink(GObject *obj)
}
}
}
- /* The default behaviour for GInitiallyUnowned subclasses is to call ref_sink().
- * - if the object is new and owned by someone else, its ref has been sunk and
- * we need to keep the one from that someone and add our own "fresh ref"
- * - if the object is not and owned by nobody, its ref is floating and we need
- * to transform it into a regular ref.
- */
- if (G_IS_INITIALLY_UNOWNED(obj)) {
+ if (G_IS_INITIALLY_UNOWNED(obj) && !g_object_is_floating(obj)) {
+ /* GtkWindow and GtkInvisible does not return a ref to caller of
+ * g_object_new.
+ */
+ g_object_ref(obj);
+ } else if (g_object_is_floating(obj)) {
g_object_ref_sink(obj);
}
}
@@ -632,6 +631,7 @@ pygobject_register_wrapper(PyObject *self)
gself = (PyGObject *)self;
+ pygobject_sink(gself->obj);
g_assert(gself->obj->ref_count >= 1);
/* save wrapper pointer so we can access it later */
g_object_set_qdata_full(gself->obj, pygobject_wrapper_key, gself, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]