From 7e1459b2a29045527a4bf3c5a840a2c38933760a Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 23 May 2011 11:42:14 -0300 Subject: Generate code using the new pyside class DestroyListener. Reviewer: Marcelo Lira Hugo Parente Lima --- generator/cppgenerator.cpp | 10 ++++++++-- libshiboken/basewrapper.cpp | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp index fcd1b3706..ce0a80454 100644 --- a/generator/cppgenerator.cpp +++ b/generator/cppgenerator.cpp @@ -278,6 +278,7 @@ void CppGenerator::generateClass(QTextStream &s, const AbstractMetaClass *metaCl s << "#include " << endl; s << "#include " << endl; s << "#include " << endl; + s << "#include " << endl; } s << "#include " << endl; @@ -597,8 +598,13 @@ void CppGenerator::writeDestructorNative(QTextStream &s, const AbstractMetaClass { Indentation indentation(INDENT); s << wrapperName(metaClass) << "::~" << wrapperName(metaClass) << "()" << endl << '{' << endl; - s << INDENT << "SbkObject* wrapper = Shiboken::BindingManager::instance().retrieveWrapper(this);" << endl; - s << INDENT << "Shiboken::Object::destroy(wrapper, this);" << endl; + // kill pyobject + if (usePySideExtensions() && metaClass->isQObject()) { + s << INDENT << "PySide::DestroyListener::instance()->listen(this);" << endl; + } else { + s << INDENT << "SbkObject* wrapper = Shiboken::BindingManager::instance().retrieveWrapper(this);" << endl; + s << INDENT << "Shiboken::Object::destroy(wrapper, this);" << endl; + } s << '}' << endl; } diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp index 032bf3c68..e53e495d4 100644 --- a/libshiboken/basewrapper.cpp +++ b/libshiboken/basewrapper.cpp @@ -188,7 +188,8 @@ void SbkDeallocWrapper(PyObject* pyObj) sbkType->d->cpp_dtor(sbkObj->d->cptr[0]); } } - Shiboken::Object::deallocData(sbkObj, !sbkObj->d->containsCppWrapper); + //Always destroy object data during the python object destruction + Shiboken::Object::deallocData(sbkObj, true); } void SbkDeallocWrapperWithPrivateDtor(PyObject* self) @@ -940,7 +941,6 @@ void removeParent(SbkObject* child, bool giveOwnershipBack, bool keepReference) if (!pInfo || !pInfo->parent) { return; } - ChildrenList& oldBrothers = pInfo->parent->d->parentInfo->children; // Verify if this child is part of parent list ChildrenList::iterator iChild = std::find(oldBrothers.begin(), oldBrothers.end(), child); -- cgit v1.2.3