Methods didn't check for zombies which could crash in the case where a method for an object is kept.
func = ob.getMass ...remove ob... func() # crash 2 More refcount fixes spotted by Benoit too
This commit is contained in:
@@ -225,30 +225,35 @@ typedef struct {
|
|||||||
#define KX_PYMETHOD(class_name, method_name) \
|
#define KX_PYMETHOD(class_name, method_name) \
|
||||||
PyObject* Py##method_name(PyObject* args, PyObject* kwds); \
|
PyObject* Py##method_name(PyObject* args, PyObject* kwds); \
|
||||||
static PyObject* sPy##method_name( PyObject* self, PyObject* args, PyObject* kwds) { \
|
static PyObject* sPy##method_name( PyObject* self, PyObject* args, PyObject* kwds) { \
|
||||||
|
if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "() - " BGE_PROXY_ERROR_MSG); return NULL; } \
|
||||||
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(args, kwds); \
|
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(args, kwds); \
|
||||||
}; \
|
}; \
|
||||||
|
|
||||||
#define KX_PYMETHOD_VARARGS(class_name, method_name) \
|
#define KX_PYMETHOD_VARARGS(class_name, method_name) \
|
||||||
PyObject* Py##method_name(PyObject* args); \
|
PyObject* Py##method_name(PyObject* args); \
|
||||||
static PyObject* sPy##method_name( PyObject* self, PyObject* args) { \
|
static PyObject* sPy##method_name( PyObject* self, PyObject* args) { \
|
||||||
|
if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "() - " BGE_PROXY_ERROR_MSG); return NULL; } \
|
||||||
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(args); \
|
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(args); \
|
||||||
}; \
|
}; \
|
||||||
|
|
||||||
#define KX_PYMETHOD_NOARGS(class_name, method_name) \
|
#define KX_PYMETHOD_NOARGS(class_name, method_name) \
|
||||||
PyObject* Py##method_name(); \
|
PyObject* Py##method_name(); \
|
||||||
static PyObject* sPy##method_name( PyObject* self) { \
|
static PyObject* sPy##method_name( PyObject* self) { \
|
||||||
|
if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "() - " BGE_PROXY_ERROR_MSG); return NULL; } \
|
||||||
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(); \
|
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(); \
|
||||||
}; \
|
}; \
|
||||||
|
|
||||||
#define KX_PYMETHOD_O(class_name, method_name) \
|
#define KX_PYMETHOD_O(class_name, method_name) \
|
||||||
PyObject* Py##method_name(PyObject* value); \
|
PyObject* Py##method_name(PyObject* value); \
|
||||||
static PyObject* sPy##method_name( PyObject* self, PyObject* value) { \
|
static PyObject* sPy##method_name( PyObject* self, PyObject* value) { \
|
||||||
|
if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "(value) - " BGE_PROXY_ERROR_MSG); return NULL; } \
|
||||||
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(value); \
|
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(value); \
|
||||||
}; \
|
}; \
|
||||||
|
|
||||||
#define KX_PYMETHOD_DOC(class_name, method_name) \
|
#define KX_PYMETHOD_DOC(class_name, method_name) \
|
||||||
PyObject* Py##method_name(PyObject* args, PyObject* kwds); \
|
PyObject* Py##method_name(PyObject* args, PyObject* kwds); \
|
||||||
static PyObject* sPy##method_name( PyObject* self, PyObject* args, PyObject* kwds) { \
|
static PyObject* sPy##method_name( PyObject* self, PyObject* args, PyObject* kwds) { \
|
||||||
|
if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "(...) - " BGE_PROXY_ERROR_MSG); return NULL; } \
|
||||||
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(args, kwds); \
|
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(args, kwds); \
|
||||||
}; \
|
}; \
|
||||||
static const char method_name##_doc[]; \
|
static const char method_name##_doc[]; \
|
||||||
@@ -256,6 +261,7 @@ typedef struct {
|
|||||||
#define KX_PYMETHOD_DOC_VARARGS(class_name, method_name) \
|
#define KX_PYMETHOD_DOC_VARARGS(class_name, method_name) \
|
||||||
PyObject* Py##method_name(PyObject* args); \
|
PyObject* Py##method_name(PyObject* args); \
|
||||||
static PyObject* sPy##method_name( PyObject* self, PyObject* args) { \
|
static PyObject* sPy##method_name( PyObject* self, PyObject* args) { \
|
||||||
|
if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "(...) - " BGE_PROXY_ERROR_MSG); return NULL; } \
|
||||||
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(args); \
|
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(args); \
|
||||||
}; \
|
}; \
|
||||||
static const char method_name##_doc[]; \
|
static const char method_name##_doc[]; \
|
||||||
@@ -263,6 +269,7 @@ typedef struct {
|
|||||||
#define KX_PYMETHOD_DOC_O(class_name, method_name) \
|
#define KX_PYMETHOD_DOC_O(class_name, method_name) \
|
||||||
PyObject* Py##method_name(PyObject* value); \
|
PyObject* Py##method_name(PyObject* value); \
|
||||||
static PyObject* sPy##method_name( PyObject* self, PyObject* value) { \
|
static PyObject* sPy##method_name( PyObject* self, PyObject* value) { \
|
||||||
|
if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "(value) - " BGE_PROXY_ERROR_MSG); return NULL; } \
|
||||||
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(value); \
|
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(value); \
|
||||||
}; \
|
}; \
|
||||||
static const char method_name##_doc[]; \
|
static const char method_name##_doc[]; \
|
||||||
@@ -270,6 +277,7 @@ typedef struct {
|
|||||||
#define KX_PYMETHOD_DOC_NOARGS(class_name, method_name) \
|
#define KX_PYMETHOD_DOC_NOARGS(class_name, method_name) \
|
||||||
PyObject* Py##method_name(); \
|
PyObject* Py##method_name(); \
|
||||||
static PyObject* sPy##method_name( PyObject* self) { \
|
static PyObject* sPy##method_name( PyObject* self) { \
|
||||||
|
if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "() - " BGE_PROXY_ERROR_MSG); return NULL; } \
|
||||||
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(); \
|
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(); \
|
||||||
}; \
|
}; \
|
||||||
static const char method_name##_doc[]; \
|
static const char method_name##_doc[]; \
|
||||||
|
@@ -1726,7 +1726,7 @@ PyObject* KX_GameObject::pyattr_get_meshes(void *self_v, const KX_PYATTRIBUTE_DE
|
|||||||
for(i=0; i < (int)self->m_meshes.size(); i++)
|
for(i=0; i < (int)self->m_meshes.size(); i++)
|
||||||
{
|
{
|
||||||
KX_MeshProxy* meshproxy = new KX_MeshProxy(self->m_meshes[i]);
|
KX_MeshProxy* meshproxy = new KX_MeshProxy(self->m_meshes[i]);
|
||||||
PyList_SET_ITEM(meshes, i, meshproxy->GetProxy());
|
PyList_SET_ITEM(meshes, i, meshproxy->NewProxy(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
return meshes;
|
return meshes;
|
||||||
|
@@ -1847,5 +1847,9 @@ KX_PYMETHODDEF_DOC(KX_Scene, addObject,
|
|||||||
|
|
||||||
|
|
||||||
SCA_IObject* replica = AddReplicaObject((SCA_IObject*)ob, other, time);
|
SCA_IObject* replica = AddReplicaObject((SCA_IObject*)ob, other, time);
|
||||||
|
|
||||||
|
// release here because AddReplicaObject AddRef's
|
||||||
|
// the object is added to the scene so we dont want python to own a reference
|
||||||
|
replica->Release();
|
||||||
return replica->GetProxy();
|
return replica->GetProxy();
|
||||||
}
|
}
|
Reference in New Issue
Block a user