diff options
Diffstat (limited to 'gobject')
| -rw-r--r-- | gobject/pygobject.c | 4 | ||||
| -rw-r--r-- | gobject/pygobject.h | 14 |
2 files changed, 17 insertions, 1 deletions
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) |
