summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2010-11-21 19:01:57 -0300
committerRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2010-11-22 10:43:38 -0300
commit934f291fd9ce8a14fcf75b167a592706dfbcb826 (patch)
tree9d8cdc7f072f6e1f91373f692b6555b70afa9370
parentf7cb52d3822cb8d1897498cf04ca58813c530af6 (diff)
downloadpyside-934f291fd9ce8a14fcf75b167a592706dfbcb826.tar.gz
pyside-934f291fd9ce8a14fcf75b167a592706dfbcb826.tar.xz
pyside-934f291fd9ce8a14fcf75b167a592706dfbcb826.zip
Separates QObjects with python ownership before start destructing then.
This avoid list changes during the destruction. Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Marcelo Lira <marcelo.lira@openbossa.org>
-rw-r--r--libpyside/pyside.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/libpyside/pyside.cpp b/libpyside/pyside.cpp
index 63889a0..ec62fff 100644
--- a/libpyside/pyside.cpp
+++ b/libpyside/pyside.cpp
@@ -114,12 +114,21 @@ void destroyQCoreApplication()
PyTypeObject* pyQObjectType = Shiboken::TypeResolver::get("QObject*")->pythonType();
assert(pyQObjectType);
+ QList<SbkObject*> objects;
+
+ //filter only QObjects which we have ownership, this will avoid list changes during the destruction of some parent object
foreach (SbkObject* pyObj, bm.getAllPyObjects()) {
if (pyObj != pyQApp && PyObject_TypeCheck(pyObj, pyQObjectType)) {
if (Shiboken::Wrapper::hasOwnership(pyObj))
- Shiboken::callCppDestructor<QObject>(Shiboken::Wrapper::cppPointer(pyObj, Shiboken::SbkType<QObject*>()));
+ objects << pyObj;
}
}
+
+ //Now we can destroy all object in the list
+ foreach (SbkObject* pyObj, objects)
+ Shiboken::callCppDestructor<QObject>(Shiboken::Wrapper::cppPointer(pyObj, Shiboken::SbkType<QObject*>()));
+
+ // in the end destroy app
delete app;
}