diff options
Diffstat (limited to 'PySide/QtGui/glue/qapplication_init.cpp')
-rw-r--r-- | PySide/QtGui/glue/qapplication_init.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/PySide/QtGui/glue/qapplication_init.cpp b/PySide/QtGui/glue/qapplication_init.cpp index 699633a1d..208d59a52 100644 --- a/PySide/QtGui/glue/qapplication_init.cpp +++ b/PySide/QtGui/glue/qapplication_init.cpp @@ -4,19 +4,29 @@ extern PyObject* moduleQtGui; static int QApplicationArgCount; static char** QApplicationArgValues; static const char QAPP_MACRO[] = "qApp"; -static bool leavingPython = false; void DeleteQApplicationAtExit() { - leavingPython = true; PySide::SignalManager::instance().clear(); QCoreApplication* cpp = QApplication::instance(); if (cpp) { Shiboken::BindingManager &bmngr = Shiboken::BindingManager::instance(); - PyObject* pySelf = bmngr.retrieveWrapper(cpp); - if (pySelf) + cpp->flush(); + + // Delete all widgets, this is slow but is necessary to avoid problems with python object + foreach(QWidget* w, QApplication::allWidgets()) { + PyObject* pySelf = bmngr.retrieveWrapper(w); + + w->deleteLater(); + //Make sure all events will send before invalidated the python object + QApplication::processEvents(); bmngr.invalidateWrapper(pySelf); + } + + PyObject* pySelf = bmngr.retrieveWrapper(cpp); cpp->deleteLater(); + QApplication::processEvents(); + bmngr.invalidateWrapper(pySelf); } } @@ -62,7 +72,7 @@ int SbkQApplication_Init(PyObject* self, PyObject* args, PyObject*) } PyObject_SetAttrString(moduleQtGui, QAPP_MACRO, self); - Py_AtExit(DeleteQApplicationAtExit); + PySide::registerCleanupFunction(DeleteQApplicationAtExit); Py_INCREF(self); return 1; } |