aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-03-21 15:11:03 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:54:04 -0300
commit44f5f6261876d508d52826534f7f77270c2b31ce (patch)
tree8fce06b80b59b5714cc56ef8e102ce94933c5c4e
parent69abc806ec895239154287779dca9c4cac8adcea (diff)
Fix bug 728 - "QFileDialog.getOpenFileNames never returns (hangs)"
Reviewer: Lauro Moura <lauro.neto@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
-rw-r--r--PySide/typesystem_templates.xml38
-rw-r--r--tests/QtGui/CMakeLists.txt1
-rw-r--r--tests/QtGui/bug_728.py8
3 files changed, 47 insertions, 0 deletions
diff --git a/PySide/typesystem_templates.xml b/PySide/typesystem_templates.xml
index e13b78d9e..9ef317d55 100644
--- a/PySide/typesystem_templates.xml
+++ b/PySide/typesystem_templates.xml
@@ -31,47 +31,65 @@
<!-- Templates to fix bool* parameters -->
<template name="fix_bool*">
bool ok_;
+ PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS
%RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(&amp;ok_);
+ PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS
%PYARG_0 = Shiboken::makeTuple(retval_, ok_);
</template>
<template name="fix_args,bool*">
bool ok_;
+ PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS
%RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, &amp;ok_);
+ PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS
%PYARG_0 = Shiboken::makeTuple(retval_, ok_);
</template>
<template name="fix_arg,bool*,arg">
bool ok_;
+ PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS
%RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, &amp;ok_, %3);
+ PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS
%PYARG_0 = Shiboken::makeTuple(retval_, ok_);
</template>
<template name="fix_bool*,arg">
bool ok_;
+ PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS
%RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(&amp;ok_, %2);
+ PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS
%PYARG_0 = Shiboken::makeTuple(retval_, ok_);
</template>
<template name="fix_bool*,arg,arg">
bool ok_;
+ PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS
%RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(&amp;ok_, %2, %3);
+ PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS
%PYARG_0 = Shiboken::makeTuple(retval_, ok_);
</template>
<template name="fix_bool*,arg,arg,arg">
bool ok_;
+ PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS
%RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(&amp;ok_, %2, %3, %4);
+ PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS
%PYARG_0 = Shiboken::makeTuple(retval_, ok_);
</template>
<template name="fix_arg,arg,arg,arg,arg,arg,arg,bool*,arg">
bool ok_;
+ PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS
%RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, %5, %6, %7, &amp;ok_, %9);
+ PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS
%PYARG_0 = Shiboken::makeTuple(retval_, ok_);
</template>
<template name="fix_arg,arg,arg,arg,arg,arg,bool*,arg">
bool ok_;
+ PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS
%RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, %5, %6, &amp;ok_, %8);
+ PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS
%PYARG_0 = Shiboken::makeTuple(retval_, ok_);
</template>
<template name="fix_arg,arg,arg,arg,arg,bool*,arg">
bool ok_;
+ PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS
%RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, %5, &amp;ok_, %7);
+ PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS
%PYARG_0 = Shiboken::makeTuple(retval_, ok_);
</template>
<template name="get_slice">
@@ -102,37 +120,49 @@
<template name="fix_args,QRectF*">
QRectF rect_;
+ PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS
%CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, &amp;rect_);
+ PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS
%PYARG_0 = %CONVERTTOPYTHON[QRectF](rect_);
</template>
<template name="fix_args,QRect*">
QRect rect_;
+ PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS
%CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, &amp;rect_);
+ PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS
%PYARG_0 = %CONVERTTOPYTHON[QRect](rect_);
</template>
<template name="fix_char*">
char val_;
+ PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS
%RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(&amp;val_);
+ PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS
%PYARG_0 = Shiboken::makeTuple(retval_, val_);
</template>
<template name="fix_int*,int*,int*,int*">
int a, b, c, d;
+ PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS
%CPPSELF.%FUNCTION_NAME(&amp;a, &amp;b, &amp;c, &amp;d);
+ PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS
%PYARG_0 = Shiboken::makeTuple(a, b, c, d);
</template>
<template name="fix_qreal*,qreal*,qreal*,qreal*">
qreal a, b, c, d;
+ PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS
%CPPSELF.%FUNCTION_NAME(&amp;a, &amp;b, &amp;c, &amp;d);
+ PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS
%PYARG_0 = Shiboken::makeTuple(a, b, c, d);
</template>
<template name="fix_int*,int*,int*,int*,int*">
int a, b, c, d, e;
+ PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS
%CPPSELF.%FUNCTION_NAME(&amp;a, &amp;b, &amp;c, &amp;d, &amp;e);
+ PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS
%PYARG_0 = Shiboken::makeTuple(a, b, c, d, e);
</template>
<template name="fix_qreal*,qreal*,qreal*,qreal*,qreal*">
@@ -151,7 +181,9 @@
<template name="fix_return_args,int*">
RETURNTYPE _ret;
int _arg;
+ PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS
_ret = %CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, &amp;_arg);
+ PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS
%PYARG_0 = Shiboken::makeTuple(_ret, _arg);
</template>
@@ -165,7 +197,9 @@
<template name="fix_arg,int*,int*">
%RETURN_TYPE _ret;
int a, b;
+ PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS
_ret = %CPPSELF.%FUNCTION_NAME(%1, &amp;a, &amp;b);
+ PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS
%PYARG_0 = Shiboken::makeTuple(_ret, a, b);
</template>
@@ -174,12 +208,16 @@
</template>
<template name="return_tuple_QValidator_QString_int">
+ PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS
%RETURN_TYPE retval_ = %RETURN_TYPE(%CPPSELF.%FUNCTION_NAME(%1, %2));
+ PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS
%PYARG_0 = Shiboken::makeTuple(retval_, %1, %2);
</template>
<template name="return_for_QFileDialog">
+ PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS
%RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, %5, %6);
+ PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS
%PYARG_0 = Shiboken::makeTuple(retval_, %4);
</template>
<template name="set_qapp_parent_for_orphan">
diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt
index 615e13143..76f3e06f6 100644
--- a/tests/QtGui/CMakeLists.txt
+++ b/tests/QtGui/CMakeLists.txt
@@ -44,6 +44,7 @@ PYSIDE_TEST(bug_675.py)
PYSIDE_TEST(bug_696.py)
PYSIDE_TEST(bug_693.py)
PYSIDE_TEST(bug_714.py)
+PYSIDE_TEST(bug_728.py)
PYSIDE_TEST(customproxywidget_test.py)
PYSIDE_TEST(deepcopy_test.py)
PYSIDE_TEST(float_to_int_implicit_conversion_test.py)
diff --git a/tests/QtGui/bug_728.py b/tests/QtGui/bug_728.py
new file mode 100644
index 000000000..f9a5c8b1e
--- /dev/null
+++ b/tests/QtGui/bug_728.py
@@ -0,0 +1,8 @@
+from PySide.QtGui import *
+from PySide.QtCore import *
+
+app = QApplication([])
+QTimer.singleShot(200, app.quit)
+
+# This test for a dead lock in QFileDialog.getOpenFileNames, the test fail with a timeout if the dead lock exists.
+QFileDialog.getOpenFileNames(None, "caption", QDir.homePath(), None, QFileDialog.DontUseNativeDialog)