aboutsummaryrefslogtreecommitdiffstats
path: root/libpyside
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-10-22 17:28:43 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2010-10-22 19:16:51 -0200
commit77a1654ad587241d3c14bafa2c0deae53e1599ee (patch)
tree1b2dece9fe99a5a956420e03229d0872916a9a05 /libpyside
parent800fb4613cb61dbff33750ec0ab4b18ca3369c6c (diff)
Fix bugs 430, 426, 429, 394, 433.
These bugs are about QApplication instance being destroyed before some QObject. Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Renato Araújo <renato.filho@openbossa.org>
Diffstat (limited to 'libpyside')
-rw-r--r--libpyside/pyside.cpp26
-rw-r--r--libpyside/pyside.h5
2 files changed, 31 insertions, 0 deletions
diff --git a/libpyside/pyside.cpp b/libpyside/pyside.cpp
index 7d9230016..c2e14350b 100644
--- a/libpyside/pyside.cpp
+++ b/libpyside/pyside.cpp
@@ -24,9 +24,11 @@
#include "pyside.h"
#include <basewrapper.h>
#include <conversions.h>
+#include <typeresolver.h>
#include <algorithm>
#include <cctype>
#include <QStack>
+#include <QCoreApplication>
#include "signalmanager.h"
#include "qproperty_p.h"
#include "qproperty.h"
@@ -98,5 +100,29 @@ void runCleanupFunctions()
}
}
+void destroyQCoreApplication()
+{
+ SignalManager::instance().clear();
+ QCoreApplication* app = QCoreApplication::instance();
+ if (!app)
+ return;
+
+ Shiboken::BindingManager& bm = Shiboken::BindingManager::instance();
+ PyObject* pyQApp = bm.retrieveWrapper(app);
+ PyTypeObject* pyQObjectType = Shiboken::TypeResolver::get("QObject*")->pythonType();
+ assert(pyQObjectType);
+
+ foreach (PyObject* pyObj, bm.getAllPyObjects()) {
+ if (pyObj != pyQApp && PyObject_TypeCheck(pyObj, pyQObjectType)) {
+ if (SbkBaseWrapper_hasOwnership(pyObj)) {
+ bm.destroyWrapper(pyObj);
+ delete static_cast<QObject*>(Shiboken::getCppPointer(pyObj, Shiboken::SbkType<QObject*>()));
+ }
+ }
+ }
+ app->flush();
+ delete app;
+}
+
} //namespace PySide
diff --git a/libpyside/pyside.h b/libpyside/pyside.h
index 2c5afb536..fe9ce3a6e 100644
--- a/libpyside/pyside.h
+++ b/libpyside/pyside.h
@@ -84,6 +84,11 @@ typedef void (*CleanupFunction)(void);
PYSIDE_API void registerCleanupFunction(CleanupFunction func);
PYSIDE_API void runCleanupFunctions();
+/**
+ * Destroy a QCoreApplication taking care of destroy all instances of QObject first.
+ */
+PYSIDE_API void destroyQCoreApplication();
+
} //namespace PySide