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:
renatofilho 2010-10-04 16:15:25 -03:00
commit 73fea93181

View file

@ -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;
} }
} }