aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2011-01-03 19:54:40 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:48:07 -0300
commitcc7d8dd1386138a5e88afe64664f51c33aad2f56 (patch)
treea447067f09c84da9d9d794f651f05f18c80cebb8
parent1f1f82d5827c3ec77fcd4ee6b6ab47afa0473007 (diff)
Created support to function qAddPostRoutine.
Created unit test for bug #515 Fixes bug #515 Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Lauro Moura <lauro.neto@openbossa.org>
-rw-r--r--PySide/QtCore/typesystem_core.xml31
-rw-r--r--tests/QtCore/CMakeLists.txt1
-rw-r--r--tests/QtCore/bug_515.py18
3 files changed, 50 insertions, 0 deletions
diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml
index c785f797d..df04ca9c8 100644
--- a/PySide/QtCore/typesystem_core.xml
+++ b/PySide/QtCore/typesystem_core.xml
@@ -596,6 +596,37 @@
</inject-code>
</add-function>
+ <inject-code class="native" position="beginning">
+ namespace PySide {
+ static QStack&lt;PyObject*&gt; globalPostRoutineFunctions;
+ void globalPostRoutineCallback()
+ {
+ foreach(PyObject* callback, globalPostRoutineFunctions) {
+ Shiboken::AutoDecRef result(PyObject_CallObject(callback, NULL));
+ Py_DECREF(callback);
+ }
+ globalPostRoutineFunctions.clear();
+ }
+ void addPostRoutine(PyObject* callback)
+ {
+ if (PyCallable_Check(callback)) {
+ globalPostRoutineFunctions &lt;&lt; callback;
+ Py_INCREF(callback);
+ } else {
+ PyErr_SetString(PyExc_TypeError, "qAddPostRoutine: The argument must be a callable object.");
+ }
+ }
+ } // namespace
+ </inject-code>
+ <add-function signature="qAddPostRoutine(PyObject*)">
+ <inject-code class="target" position="beginning">
+ PySide::addPostRoutine(%1);
+ </inject-code>
+ </add-function>
+ <inject-code class="target" position="end">
+ qAddPostRoutine(PySide::globalPostRoutineCallback);
+ </inject-code>
+
<inject-code class="target" position="end" file="glue/qt_version.cpp" />
<add-function signature="__moduleShutdown()">
diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt
index 8ec3cdd66..685191549 100644
--- a/tests/QtCore/CMakeLists.txt
+++ b/tests/QtCore/CMakeLists.txt
@@ -4,6 +4,7 @@ PYSIDE_TEST(bug_408.py)
PYSIDE_TEST(bug_428.py)
PYSIDE_TEST(bug_462.py)
PYSIDE_TEST(bug_505.py)
+PYSIDE_TEST(bug_515.py)
PYSIDE_TEST(blocking_signals_test.py)
PYSIDE_TEST(child_event_test.py)
PYSIDE_TEST(deepcopy_test.py)
diff --git a/tests/QtCore/bug_515.py b/tests/QtCore/bug_515.py
new file mode 100644
index 000000000..c2bd9c73b
--- /dev/null
+++ b/tests/QtCore/bug_515.py
@@ -0,0 +1,18 @@
+""" Unittest for bug #515 """
+""" http://bugs.openbossa.org/show_bug.cgi?id=515 """
+
+from PySide import QtCore
+
+callCleanup = False
+def _cleanup():
+ global callCleanup
+ callCleanup = True
+
+def _checkCleanup():
+ global callCleanup
+ assert(callCleanup)
+
+app = QtCore.QCoreApplication([])
+QtCore.qAddPostRoutine(_cleanup)
+QtCore.qAddPostRoutine(_checkCleanup)
+del app