aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2009-11-09 12:32:53 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2009-11-09 12:32:53 -0300
commita2722b07a3ff4cd2b4974118c937b57fde045902 (patch)
tree69ca229fd2586030d4727207f79e4ef6ecd58f7d
parenteb88812ff2a7fa6470758b544d577550b2c2d165 (diff)
added a Python wrapper deallocator for classes with private destructor
-rw-r--r--cppgenerator.cpp3
-rw-r--r--libshiboken/basewrapper.cpp7
-rw-r--r--libshiboken/basewrapper.h2
3 files changed, 11 insertions, 1 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp
index ae6ce32a5..07a9d983e 100644
--- a/cppgenerator.cpp
+++ b/cppgenerator.cpp
@@ -1087,8 +1087,9 @@ void CppGenerator::writeClassDefinition(QTextStream& s, const AbstractMetaClass*
if (metaClass->isNamespace() || metaClass->hasPrivateDestructor()) {
tp_flags = "Py_TPFLAGS_HAVE_CLASS";
+ tp_dealloc = metaClass->hasPrivateDestructor() ?
+ "(destructor)Shiboken::PyBaseWrapper_Dealloc_PrivateDtor" : "0";
tp_new = "0";
- tp_dealloc = "0";
} else {
tp_flags = "Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES";
tp_dealloc = QString("(destructor)&(Shiboken::PyBaseWrapper_Dealloc< %1 >)").arg(cppClassName);
diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp
index 43f43239b..d224e1ca9 100644
--- a/libshiboken/basewrapper.cpp
+++ b/libshiboken/basewrapper.cpp
@@ -52,4 +52,11 @@ PyBaseWrapper_New(PyTypeObject* instanceType, PyTypeObject* baseWrapperType, con
return self;
}
+void
+PyBaseWrapper_Dealloc_PrivateDtor(PyObject* self)
+{
+ BindingManager::instance().releaseWrapper(self);
+ Py_TYPE(((PyBaseWrapper*)self))->tp_free((PyObject*)self);
+}
+
} // namespace Shiboken
diff --git a/libshiboken/basewrapper.h b/libshiboken/basewrapper.h
index 053465da6..c59d3653b 100644
--- a/libshiboken/basewrapper.h
+++ b/libshiboken/basewrapper.h
@@ -137,6 +137,8 @@ PyBaseWrapper_Dealloc(PyObject* self)
Py_TYPE(((PyBaseWrapper*)self))->tp_free((PyObject*)self);
}
+PyAPI_FUNC(void) PyBaseWrapper_Dealloc_PrivateDtor(PyObject* self);
+
} // namespace Shiboken
#endif // BASEWRAPPER_H