fix garbage collection (Modules/gcmodule.c:380: move_unreachable: Assertion
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Thu, 23 Oct 2008 23:57:36 +0000 (23:57 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Thu, 23 Oct 2008 23:57:36 +0000 (23:57 +0000)
`gc->gc.gc_refs > 0`)

lib/base/ebase.cpp
lib/python/connections.cpp
lib/python/connections.h

index 62746f4..bcfab61 100644 (file)
@@ -368,16 +368,19 @@ struct eTimerPy
 static int
 eTimerPy_traverse(eTimerPy *self, visitproc visit, void *arg)
 {
 static int
 eTimerPy_traverse(eTimerPy *self, visitproc visit, void *arg)
 {
-       PyObject *obj = self->tm->timeout.get();
-       Py_VISIT(obj);
+       PyObject *obj = self->tm->timeout.get(true);
+       if (obj) {
+               Py_VISIT(obj);
+       }
        return 0;
 }
 
 static int
 eTimerPy_clear(eTimerPy *self)
 {
        return 0;
 }
 
 static int
 eTimerPy_clear(eTimerPy *self)
 {
-       PyObject *obj = self->tm->timeout.get();
-       Py_CLEAR(obj);
+       PyObject *obj = self->tm->timeout.get(true);
+       if (obj)
+               Py_CLEAR(obj);
        return 0;
 }
 
        return 0;
 }
 
@@ -572,16 +575,18 @@ struct eSocketNotifierPy
 static int
 eSocketNotifierPy_traverse(eSocketNotifierPy *self, visitproc visit, void *arg)
 {
 static int
 eSocketNotifierPy_traverse(eSocketNotifierPy *self, visitproc visit, void *arg)
 {
-       PyObject *obj = self->sn->activated.get();
-       Py_VISIT(obj);
+       PyObject *obj = self->sn->activated.get(true);
+       if (obj)
+               Py_VISIT(obj);
        return 0;
 }
 
 static int
 eSocketNotifierPy_clear(eSocketNotifierPy *self)
 {
        return 0;
 }
 
 static int
 eSocketNotifierPy_clear(eSocketNotifierPy *self)
 {
-       PyObject *obj = self->sn->activated.get();
-       Py_CLEAR(obj);
+       PyObject *obj = self->sn->activated.get(true);
+       if (obj)
+               Py_CLEAR(obj);
        return 0;
 }
 
        return 0;
 }
 
index 00f33f7..864e552 100644 (file)
@@ -20,10 +20,12 @@ void PSignal::callPython(ePyObject tuple)
        }
 }
 
        }
 }
 
-PyObject *PSignal::get()
+PyObject *PSignal::get(bool steal)
 {
 {
-       if (!m_list)
-               m_list = PyList_New(0);
-       Py_INCREF(m_list);
+       if (!steal) {
+               if (!m_list)
+                       m_list = PyList_New(0);
+               Py_INCREF(m_list);
+       }
        return m_list;
 }
        return m_list;
 }
index 8ff3a62..76859e7 100644 (file)
@@ -18,7 +18,7 @@ public:
        PSignal();
        ~PSignal();
        void callPython(SWIG_PYOBJECT(ePyObject) tuple);
        PSignal();
        ~PSignal();
        void callPython(SWIG_PYOBJECT(ePyObject) tuple);
-       PyObject *get();
+       PyObject *get(bool steal=false);
 };
 
 inline PyObject *PyFrom(int v)
 };
 
 inline PyObject *PyFrom(int v)