aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/PySide2/glue
diff options
context:
space:
mode:
authorCristián Maureira-Fredes <cristian.maureira-fredes@qt.io>2020-02-06 18:32:53 +0100
committerCristian Maureira-Fredes <cristian.maureira-fredes@qt.io>2020-03-13 08:15:21 +0100
commit4106f1420119f77b41246836f1829431a1c58395 (patch)
treec0769fbe0416421ec6d4512e57d421766ffd1c47 /sources/pyside2/PySide2/glue
parent4df39cb75da522e5daff583e6fc11ca897969628 (diff)
Adjust the allow-thread behavior
This adds and remove the usage of: allow-thread="yes" in some typesystem entries. This also adapt the usage of the Py_BEGIN/END_ALLOW_THREAD macro inside the snippets used by other typesystem entries. The main reason is that in some cases not the whole snippet requires to be inside such state, but only when calling the C++ equivalent function. Task-number: PYSIDE-803 Change-Id: Ifa9c8cee2713c453e4d5c624aaa862e75559180c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside2/PySide2/glue')
-rw-r--r--sources/pyside2/PySide2/glue/qtcore.cpp39
-rw-r--r--sources/pyside2/PySide2/glue/qtgui.cpp4
-rw-r--r--sources/pyside2/PySide2/glue/qtwidgets.cpp6
3 files changed, 25 insertions, 24 deletions
diff --git a/sources/pyside2/PySide2/glue/qtcore.cpp b/sources/pyside2/PySide2/glue/qtcore.cpp
index e54fa1846..b870afa55 100644
--- a/sources/pyside2/PySide2/glue/qtcore.cpp
+++ b/sources/pyside2/PySide2/glue/qtcore.cpp
@@ -63,10 +63,15 @@ bool py2kStrCheck(PyObject *obj)
// defaultValue can also be passed as positional argument,
// not only as keyword.
QVariant out;
-if (kwds || numArgs > 1)
+if (kwds || numArgs > 1) {
+ Py_BEGIN_ALLOW_THREADS
out = %CPPSELF.value(%1, %2);
-else
+ Py_END_ALLOW_THREADS
+} else {
+ Py_BEGIN_ALLOW_THREADS
out = %CPPSELF.value(%1);
+ Py_END_ALLOW_THREADS
+}
PyTypeObject *typeObj = reinterpret_cast<PyTypeObject*>(%PYARG_3);
@@ -393,9 +398,7 @@ static bool qobjectConnect(QObject *source, const char *signal, QObject *receive
slot++;
PySide::SignalManager::registerMetaMethod(receiver, slot, isSignal ? QMetaMethod::Signal : QMetaMethod::Slot);
bool connection;
- Py_BEGIN_ALLOW_THREADS
connection = QObject::connect(source, signal - 1, receiver, slot - 1, type);
- Py_END_ALLOW_THREADS
return connection;
}
@@ -451,9 +454,7 @@ static bool qobjectConnectCallback(QObject *source, const char *signal, PyObject
}
}
bool connection;
- Py_BEGIN_ALLOW_THREADS
connection = QMetaObject::connect(source, signalIndex, receiver, slotIndex, type);
- Py_END_ALLOW_THREADS
if (connection) {
if (usingGlobalReceiver)
signalManager.notifyGlobalReceiver(receiver);
@@ -499,9 +500,7 @@ static bool qobjectDisconnectCallback(QObject *source, const char *signal, PyObj
slotMethod = metaObject->method(slotIndex);
bool disconnected;
- Py_BEGIN_ALLOW_THREADS
disconnected = QMetaObject::disconnectOne(source, signalIndex, receiver, slotIndex);
- Py_END_ALLOW_THREADS
if (disconnected) {
if (usingGlobalReceiver)
@@ -577,8 +576,10 @@ bool %0 = qobjectConnect(%1, %2, %3, %4, %5);
// qFatal doesn't have a stream version, so we do a
// qWarning call followed by a qFatal() call using a
// literal.
+Py_BEGIN_ALLOW_THREADS
qWarning() << %1;
qFatal("[A qFatal() call was made from Python code]");
+Py_END_ALLOW_THREADS
// @snippet qfatal
// @snippet moduleshutdown
@@ -669,9 +670,7 @@ if (!PyDateTimeAPI)
// @snippet qdate-getdate
int year, month, day;
-%BEGIN_ALLOW_THREADS
%CPPSELF.%FUNCTION_NAME(&year, &month, &day);
-%END_ALLOW_THREADS
%PYARG_0 = PyTuple_New(3);
PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[int](year));
PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[int](month));
@@ -680,9 +679,7 @@ PyTuple_SET_ITEM(%PYARG_0, 2, %CONVERTTOPYTHON[int](day));
// @snippet qdate-weeknumber
int yearNumber;
-%BEGIN_ALLOW_THREADS
int week = %CPPSELF.%FUNCTION_NAME(&yearNumber);
-%END_ALLOW_THREADS
%PYARG_0 = PyTuple_New(2);
PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[int](week));
PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[int](yearNumber));
@@ -1439,7 +1436,10 @@ Py_XINCREF(%PYARG_0);
// @snippet qdatastream-readrawdata
QByteArray data;
data.resize(%2);
-int result = %CPPSELF.%FUNCTION_NAME(data.data(), data.size());
+int result = 0;
+Py_BEGIN_ALLOW_THREADS
+result = %CPPSELF.%FUNCTION_NAME(data.data(), data.size());
+Py_END_ALLOW_THREADS
if (result == -1) {
Py_INCREF(Py_None);
%PYARG_0 = Py_None;
@@ -1449,7 +1449,10 @@ if (result == -1) {
// @snippet qdatastream-readrawdata
// @snippet qdatastream-writerawdata
-int r = %CPPSELF.%FUNCTION_NAME(%1, Shiboken::String::len(%PYARG_1));
+int r = 0;
+Py_BEGIN_ALLOW_THREADS
+r = %CPPSELF.%FUNCTION_NAME(%1, Shiboken::String::len(%PYARG_1));
+Py_END_ALLOW_THREADS
%PYARG_0 = %CONVERTTOPYTHON[int](r);
// @snippet qdatastream-writerawdata
@@ -1580,7 +1583,9 @@ QT_END_NAMESPACE
// @snippet use-stream-for-format-security
// Uses the stream version for security reasons
// see gcc man page at -Wformat-security
+Py_BEGIN_ALLOW_THREADS
%FUNCTION_NAME() << %1;
+Py_END_ALLOW_THREADS
// @snippet use-stream-for-format-security
// @snippet qresource-registerResource
@@ -1594,12 +1599,16 @@ QT_END_NAMESPACE
// @snippet qstring-return
// @snippet stream-write-method
+Py_BEGIN_ALLOW_THREADS
(*%CPPSELF) << %1;
+Py_END_ALLOW_THREADS
// @snippet stream-write-method
// @snippet stream-read-method
%RETURN_TYPE _cpp_result;
+Py_BEGIN_ALLOW_THREADS
(*%CPPSELF) >> _cpp_result;
+Py_END_ALLOW_THREADS
%PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](_cpp_result);
// @snippet stream-read-method
@@ -1621,7 +1630,9 @@ if (PyBytes_Check(%PYARG_0)) {
// @snippet qiodevice-readData
QByteArray ba(1 + int(%2), char(0));
+Py_BEGIN_ALLOW_THREADS
%CPPSELF.%FUNCTION_NAME(ba.data(), int(%2));
+Py_END_ALLOW_THREADS
%PYARG_0 = Shiboken::String::fromCString(ba.constData());
// @snippet qiodevice-readData
diff --git a/sources/pyside2/PySide2/glue/qtgui.cpp b/sources/pyside2/PySide2/glue/qtgui.cpp
index d2480e99e..a6b45b7c0 100644
--- a/sources/pyside2/PySide2/glue/qtgui.cpp
+++ b/sources/pyside2/PySide2/glue/qtgui.cpp
@@ -78,9 +78,7 @@ QBitmap %0 = QBitmap::fromData(%1, buffer, %3);
// @snippet qbitmap-fromdata
// @snippet qtextline-cursortox
-%BEGIN_ALLOW_THREADS
%RETURN_TYPE %0 = %CPPSELF->::%TYPE::%FUNCTION_NAME(&%1, %2);
-%END_ALLOW_THREADS
%PYARG_0 = PyTuple_New(2);
PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](%0));
PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[%ARG1_TYPE](%1));
@@ -444,9 +442,7 @@ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[%ARG1_TYPE](%1));
// @snippet qclipboard-text
// @snippet qpainter-drawpolygon
-%BEGIN_ALLOW_THREADS
%CPPSELF.%FUNCTION_NAME(%1.data(), %1.size(), %2);
-%END_ALLOW_THREADS
// @snippet qpainter-drawpolygon
// @snippet qmatrix-map-point
diff --git a/sources/pyside2/PySide2/glue/qtwidgets.cpp b/sources/pyside2/PySide2/glue/qtwidgets.cpp
index 0e0b025a6..1c663364c 100644
--- a/sources/pyside2/PySide2/glue/qtwidgets.cpp
+++ b/sources/pyside2/PySide2/glue/qtwidgets.cpp
@@ -93,18 +93,14 @@ _defaultValue = %PYARG_1;
// @snippet qformlayout-fix-args
int _row;
QFormLayout::ItemRole _role;
-%BEGIN_ALLOW_THREADS
%CPPSELF->%FUNCTION_NAME(%ARGUMENT_NAMES, &_row, &_role);
-%END_ALLOW_THREADS
%PYARG_0 = PyTuple_New(2);
PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[int](_row));
PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QFormLayout::ItemRole](_role));
// @snippet qformlayout-fix-args
// @snippet qfiledialog-return
-%BEGIN_ALLOW_THREADS
%RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, &%5, %6);
-%END_ALLOW_THREADS
%PYARG_0 = PyTuple_New(2);
PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](retval_));
PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[%ARG5_TYPE](%5));
@@ -389,9 +385,7 @@ Shiboken::AutoDecRef parent(%CONVERTTOPYTHON[QGraphicsItem *](parentItem));
const auto &childItems = %1->childItems();
for (auto *item : childItems)
Shiboken::Object::setParent(parent, %CONVERTTOPYTHON[QGraphicsItem *](item));
-%BEGIN_ALLOW_THREADS
%CPPSELF.%FUNCTION_NAME(%1);
-%END_ALLOW_THREADS
// the arg was destroyed by Qt.
Shiboken::Object::invalidate(%PYARG_1);
// @snippet qgraphicsscene-destroyitemgroup