add workaround
[vuplus_dvbapp] / lib / python / connections.h
index d24bb42..ab12313 100644 (file)
 
 class PSignal
 {
+protected:
        ePyObject m_list;
+       bool *m_destroyed;
 public:
        PSignal();
        ~PSignal();
        void callPython(SWIG_PYOBJECT(ePyObject) tuple);
-       PyObject *get();
+       PyObject *get(bool steal=false);
 };
 
 inline PyObject *PyFrom(int v)
@@ -36,10 +38,18 @@ class PSignal0: public PSignal, public Signal0<R>
 public:
        R operator()()
        {
-               PyObject *pArgs = PyTuple_New(0);
-               callPython(pArgs);
-               Org_Py_DECREF(pArgs);
-               return Signal0<R>::operator()();
+               bool destroyed=false;
+               m_destroyed = &destroyed;
+               if (m_list)
+               {
+                       PyObject *pArgs = PyTuple_New(0);
+                       callPython(pArgs);
+                       Org_Py_DECREF(pArgs);
+               }
+               if (!destroyed) {
+                       m_destroyed = 0;
+                       return Signal0<R>::operator()();
+               }
        }
 };
 
@@ -49,11 +59,19 @@ class PSignal1: public PSignal, public Signal1<R,V0>
 public:
        R operator()(V0 a0)
        {
-               PyObject *pArgs = PyTuple_New(1);
-               PyTuple_SET_ITEM(pArgs, 0, PyFrom(a0));
-               callPython(pArgs);
-               Org_Py_DECREF(pArgs);
-               return Signal1<R,V0>::operator()(a0);
+               bool destroyed=false;
+               m_destroyed = &destroyed;
+               if (m_list)
+               {
+                       PyObject *pArgs = PyTuple_New(1);
+                       PyTuple_SET_ITEM(pArgs, 0, PyFrom(a0));
+                       callPython(pArgs);
+                       Org_Py_DECREF(pArgs);
+               }
+               if (!destroyed) {
+                       m_destroyed = 0;
+                       return Signal1<R,V0>::operator()(a0);
+               }
        }
 };
 
@@ -63,12 +81,20 @@ class PSignal2: public PSignal, public Signal2<R,V0,V1>
 public:
        R operator()(V0 a0, V1 a1)
        {
-               PyObject *pArgs = PyTuple_New(2);
-               PyTuple_SET_ITEM(pArgs, 0, PyFrom(a0));
-               PyTuple_SET_ITEM(pArgs, 1, PyFrom(a1));
-               callPython(pArgs);
-               Org_Py_DECREF(pArgs);
-               return Signal2<R,V0,V1>::operator()(a0, a1);
+               bool destroyed=false;
+               m_destroyed = &destroyed;
+               if (m_list)
+               {
+                       PyObject *pArgs = PyTuple_New(2);
+                       PyTuple_SET_ITEM(pArgs, 0, PyFrom(a0));
+                       PyTuple_SET_ITEM(pArgs, 1, PyFrom(a1));
+                       callPython(pArgs);
+                       Org_Py_DECREF(pArgs);
+               }
+               if (!destroyed) {
+                       m_destroyed = 0;
+                       return Signal2<R,V0,V1>::operator()(a0, a1);
+               }
        }
 };