aboutsummaryrefslogtreecommitdiffstats
path: root/PySide/QtGui/glue/qapplication_init.cpp
diff options
context:
space:
mode:
authorrenatofilho <renato.filho@openbossa.org>2010-09-17 17:03:01 -0300
committerrenatofilho <renato.filho@openbossa.org>2010-09-17 18:54:08 -0300
commit6974551674d72a828ff9ae19af510c90a62a09ec (patch)
tree1dac32e9240ede7429569b4d25b672e8c017022a /PySide/QtGui/glue/qapplication_init.cpp
parentb8436f6b1e1efb4da51c6bcc6c22d997541d10c6 (diff)
Created PySide cleanup functions used to register functions to be called before the python die.
Reviewer: Hugo Parente Lima <hugo.pl@gmail.com> Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'PySide/QtGui/glue/qapplication_init.cpp')
-rw-r--r--PySide/QtGui/glue/qapplication_init.cpp20
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;
}