aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/libpyside/signalmanager.cpp
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2020-03-30 19:46:41 +0200
committerChristian Tismer <tismer@stackless.com>2020-04-02 15:11:06 +0200
commitfe77dce7a7e713456454e5c0a071f7cc70261b98 (patch)
treebd904887a1b53856f9b95f521e8c1debe1d13b25 /sources/pyside2/libpyside/signalmanager.cpp
parent79c74e1999d2b29bc918f6d42079c34174bb137d (diff)
shiboken: Fix dict access without GIL
In PYSIDE-803 we used an optimization that accessed a dictionary without holding the GIL. This turned out to be not correct, because PyDict_GetItem works with thread state to maintain the global error variables. PyDict_GetItemWithErrors can be used instead in a way that allows releasing the GIL. Task-number: PYSIDE-803 Task-number: PYSIDE-813 Change-Id: Ifb0cbb20c21ca9c8b3d099fff1db5410eb6824b4 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside2/libpyside/signalmanager.cpp')
-rw-r--r--sources/pyside2/libpyside/signalmanager.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/sources/pyside2/libpyside/signalmanager.cpp b/sources/pyside2/libpyside/signalmanager.cpp
index 01b347a3d..0fe0d0092 100644
--- a/sources/pyside2/libpyside/signalmanager.cpp
+++ b/sources/pyside2/libpyside/signalmanager.cpp
@@ -559,7 +559,10 @@ static MetaObjectBuilder *metaBuilderFromDict(PyObject *dict)
if (!dict || !PyDict_Contains(dict, metaObjectAttr))
return nullptr;
- PyObject *pyBuilder = PyDict_GetItem(dict, metaObjectAttr);
+ // PYSIDE-813: The above assumption is not true in debug mode:
+ // PyDict_GetItem would touch PyThreadState_GET and the global error state.
+ // PyDict_GetItemWithError instead can work without GIL.
+ PyObject *pyBuilder = PyDict_GetItemWithError(dict, metaObjectAttr);
#ifdef IS_PY3K
return reinterpret_cast<MetaObjectBuilder *>(PyCapsule_GetPointer(pyBuilder, nullptr));
#else