diff options
Diffstat (limited to 'libpyside/pyside.cpp')
-rw-r--r-- | libpyside/pyside.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libpyside/pyside.cpp b/libpyside/pyside.cpp index 63889a047..ec62fffc2 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; } |