From df4fc5a5bf7bc65b610a497091f47e5ccc600874 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Thu, 9 Sep 2004 04:06:33 +0000 Subject: "" svn path=/trunk/; revision=2020 --- externals/grill/py/source/bound.cpp | 2 ++ externals/grill/py/source/pyext.cpp | 15 +++++++++++---- externals/grill/py/source/pyext.h | 2 ++ 3 files changed, 15 insertions(+), 4 deletions(-) (limited to 'externals/grill/py/source') diff --git a/externals/grill/py/source/bound.cpp b/externals/grill/py/source/bound.cpp index 75a462e4..6fe0cd2b 100644 --- a/externals/grill/py/source/bound.cpp +++ b/externals/grill/py/source/bound.cpp @@ -132,6 +132,8 @@ V pyext::ClearBinding() // in case the object couldn't be constructed... if(!pyobj) return; + FLEXT_ASSERT(GetThis(pyobj)); + void *data = NULL; const t_symbol *sym = NULL; 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 } diff --git a/externals/grill/py/source/pyext.h b/externals/grill/py/source/pyext.h index c073fa74..4b3e1b17 100644 --- a/externals/grill/py/source/pyext.h +++ b/externals/grill/py/source/pyext.h @@ -65,6 +65,8 @@ private: static V Setup(t_classid); static pyext *GetThis(PyObject *self); + void SetThis(); + V ClearBinding(); BL MakeInstance(); BL DoInit(); -- cgit v1.2.1