Fixed QCoreApplication and QApplication cleanup.

Reviewer: Hugo Parente Lima <hugo.pl@gmail.com>
          Luciano Wolf <luciano.wolf@openbossa.org>
This commit is contained in:
renatofilho 2010-09-24 15:58:00 -03:00
commit 6320bfa4fa
2 changed files with 3 additions and 7 deletions

View file

@ -10,10 +10,9 @@ void DeleteQCoreApplicationAtExit()
QCoreApplication *cpp = QCoreApplication::instance(); QCoreApplication *cpp = QCoreApplication::instance();
if (cpp) { if (cpp) {
Shiboken::BindingManager &bmngr = Shiboken::BindingManager::instance(); Shiboken::BindingManager &bmngr = Shiboken::BindingManager::instance();
PyObject* pySelf = bmngr.retrieveWrapper(cpp);
cpp->flush(); cpp->flush();
QCoreApplication::processEvents(); QCoreApplication::processEvents();
bmngr.invalidateWrapper(pySelf); bmngr.destroyWrapper(cpp);
delete cpp; delete cpp;
} }
} }

View file

@ -15,18 +15,15 @@ void DeleteQApplicationAtExit()
// 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()) {
PyObject* pySelf = bmngr.retrieveWrapper(w);
w->deleteLater(); w->deleteLater();
//Make sure all events will send before invalidated the python object //Make sure all events will send before invalidated the python object
QApplication::processEvents(); QApplication::processEvents();
bmngr.invalidateWrapper(pySelf); bmngr.destroyWrapper(w);
} }
PyObject* pySelf = bmngr.retrieveWrapper(cpp);
cpp->deleteLater(); cpp->deleteLater();
QApplication::processEvents(); QApplication::processEvents();
bmngr.invalidateWrapper(pySelf); bmngr.destroyWrapper(cpp);
} }
} }