From e0fc94bfbdae09096f73b4378686a3ec2e8e392a Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Sun, 17 Jun 2007 16:26:34 +0000 Subject: Bug 447271 – gobject has a weird bug on mac. Involves python, property and subclassing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit svn path=/trunk/; revision=677 --- ChangeLog | 11 +++++++++++ gobject/pygobject.c | 4 ++++ gobject/pygobject.h | 14 +++++++++++++- tests/test_subtype.py | 12 ++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6676c8c..6e87c8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-06-17 Gustavo J. A. M. Carneiro + + * gobject/pygobject.h: Add a flags field to PyGObject; uses + structure space formerly occupied by the now stale "GSList + *closures" field. + + * gobject/pygobject.c (pygobject_switch_to_toggle_ref): Do nothing + if the wrapper is already in toggle reference mode. Closes #447271. + + * tests/test_subtype.py: Test case for #447271. + 2007-06-17 Sebastien Bacher * m4/python.m4: use python-config to get python includes diff --git a/gobject/pygobject.c b/gobject/pygobject.c index 27f82f6..f889bc5 100644 --- a/gobject/pygobject.c +++ b/gobject/pygobject.c @@ -648,6 +648,10 @@ static inline void pygobject_switch_to_toggle_ref(PyGObject *self) { g_assert(self->obj->ref_count >= 1); + + if (self->private.flags & PYGOBJECT_USING_TOGGLE_REF) + return; /* already using toggle ref */ + self->private.flags |= PYGOBJECT_USING_TOGGLE_REF; /* Note that add_toggle_ref will never immediately call back into pyg_toggle_notify */ Py_INCREF((PyObject *) self); diff --git a/gobject/pygobject.h b/gobject/pygobject.h index 43e7906..aacb52e 100644 --- a/gobject/pygobject.h +++ b/gobject/pygobject.h @@ -25,6 +25,10 @@ struct _PyGClosure { PyClosureExceptionHandler exception_handler; }; +typedef enum { + PYGOBJECT_USING_TOGGLE_REF = 1 << 0 +} PyGObjectFlags; + /* closures is just an alias for what is found in the * PyGObjectData */ typedef struct { @@ -32,7 +36,15 @@ typedef struct { GObject *obj; PyObject *inst_dict; /* the instance dictionary -- must be last */ PyObject *weakreflist; /* list of weak references */ - GSList *closures; /* stale field; no longer updated DO-NOT-USE! */ + + /*< private >*/ + /* using union to preserve ABI compatibility (structure size + * must not change) */ + union { + GSList *closures; /* stale field; no longer updated DO-NOT-USE! */ + PyGObjectFlags flags; + } private; + } PyGObject; #define pygobject_get(v) (((PyGObject *)(v))->obj) diff --git a/tests/test_subtype.py b/tests/test_subtype.py index cfb70bb..af03b52 100644 --- a/tests/test_subtype.py +++ b/tests/test_subtype.py @@ -247,3 +247,15 @@ class TestSubType(unittest.TestCase): o = C() o.str = 'str' o.str = 'str' + + def testDescriptorV2(self): + """http://bugzilla.gnome.org/show_bug.cgi?id=447271""" + class Foo(gobject.GObject): + def set_foo(self, foo): + self._foo = foo + def get_foo(self, foo): + self._foo = foo + fooprop = property(get_foo, set_foo) + + foo = Foo() + foo.fooprop = 123 -- cgit