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>
This commit is contained in:
parent
f7cb52d382
commit
934f291fd9
1 changed files with 10 additions and 1 deletions
|
|
@ -114,12 +114,21 @@ void destroyQCoreApplication()
|
||||||
PyTypeObject* pyQObjectType = Shiboken::TypeResolver::get("QObject*")->pythonType();
|
PyTypeObject* pyQObjectType = Shiboken::TypeResolver::get("QObject*")->pythonType();
|
||||||
assert(pyQObjectType);
|
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()) {
|
foreach (SbkObject* pyObj, bm.getAllPyObjects()) {
|
||||||
if (pyObj != pyQApp && PyObject_TypeCheck(pyObj, pyQObjectType)) {
|
if (pyObj != pyQApp && PyObject_TypeCheck(pyObj, pyQObjectType)) {
|
||||||
if (Shiboken::Wrapper::hasOwnership(pyObj))
|
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;
|
delete app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue