aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/py/source/pyext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'externals/grill/py/source/pyext.cpp')
-rw-r--r--externals/grill/py/source/pyext.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/externals/grill/py/source/pyext.cpp b/externals/grill/py/source/pyext.cpp
index adaacc0e..e8440081 100644
--- a/externals/grill/py/source/pyext.cpp
+++ b/externals/grill/py/source/pyext.cpp
@@ -87,6 +87,13 @@ pyext *pyext::GetThis(PyObject *self)
}
}
+void pyext::SetThis()
+{
+ // remember the this pointer
+ PyObject *th = PyLong_FromVoidPtr(this);
+ int ret = PyObject_SetAttrString(pyobj,"_this",th); // ref is taken
+}
+
#if FLEXT_SYS == FLEXT_SYS_MAX
static short patcher_myvol(t_patcher *x)
@@ -254,11 +261,9 @@ pyext::~pyext()
BL pyext::DoInit()
{
- // remember the this pointer
- PyObject *th = PyLong_FromVoidPtr(this);
- int ret = PyObject_SetAttrString(pyobj,"_this",th); // ref is taken
+ SetThis();
- // call init now, after _this has been set, which is
+ // call init now, after _this has been set, which is
// important for eventual callbacks from __init__ to c
PyObject *pargs = MakePyArgs(NULL,args.Count(),args.Atoms(),-1,true);
if(!pargs) PyErr_Print();
@@ -330,6 +335,8 @@ V pyext::m_reload()
Reregister("_pyext"); // the others
Register("_pyext"); // self
+ SetThis();
+
PY_UNLOCK
}