Fixed QApplication cleanup.
Fixes bug #396. Reviewer: Hugo Parente Lima <hugo.pl@gmail.com> Luciano Wolf <luciano.wolf@openbossa.org>
This commit is contained in:
parent
2f8381e712
commit
73fea93181
1 changed files with 8 additions and 8 deletions
|
|
@ -11,18 +11,18 @@ void DeleteQApplicationAtExit()
|
||||||
QCoreApplication* cpp = QApplication::instance();
|
QCoreApplication* cpp = QApplication::instance();
|
||||||
if (cpp) {
|
if (cpp) {
|
||||||
Shiboken::BindingManager &bmngr = Shiboken::BindingManager::instance();
|
Shiboken::BindingManager &bmngr = Shiboken::BindingManager::instance();
|
||||||
cpp->flush();
|
|
||||||
|
|
||||||
// Delete all widgets, this is slow but is necessary to avoid problems with python object
|
// Delete all widgets, this is slow but is necessary to avoid problems with python object
|
||||||
foreach(QWidget* w, QApplication::allWidgets()) {
|
foreach(QWidget* w, QApplication::allWidgets()) {
|
||||||
w->deleteLater();
|
PyObject* wrapper = bmngr.retrieveWrapper(w);
|
||||||
//Make sure all events will send before invalidated the python object
|
if (wrapper) {
|
||||||
QApplication::processEvents();
|
if (SbkBaseWrapper_hasOwnership(wrapper))
|
||||||
bmngr.destroyWrapper(w);
|
delete w; // destroy C++ object and invalidate wrapper object
|
||||||
|
else
|
||||||
|
bmngr.destroyWrapper(wrapper); // only invalidate wrapper object
|
||||||
}
|
}
|
||||||
|
}
|
||||||
cpp->processEvents();
|
cpp->flush();
|
||||||
bmngr.destroyWrapper(cpp);
|
|
||||||
delete cpp;
|
delete cpp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue