aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2011-05-23 11:42:14 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:15:23 -0300
commit7e1459b2a29045527a4bf3c5a840a2c38933760a (patch)
tree15e00fd309dccca2b2d0d18b591ac42b03df2acb
parent95f7d0a2c1a417e81bf2cab00075e28a8d22660f (diff)
Generate code using the new pyside class DestroyListener.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Hugo Parente Lima <hugo.pl@gmail.com>
-rw-r--r--generator/cppgenerator.cpp10
-rw-r--r--libshiboken/basewrapper.cpp4
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 <pysidesignal.h>" << endl;
s << "#include <pysideproperty.h>" << endl;
s << "#include <pyside.h>" << endl;
+ s << "#include <destroylistener.h>" << endl;
}
s << "#include <typeresolver.h>" << 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);