aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/PySide2/glue
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-06-26 17:53:49 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-06-26 17:53:49 +0200
commit41b49a16d62f5c759e4f8053cefa10b3f0390b31 (patch)
treee0a24fb8f1f96021220eb5fc894fccfac2247189 /sources/pyside2/PySide2/glue
parentff94459c809e2ccd13e6d669b053667d35b3e571 (diff)
parent52f29458d7d6cb379d28d84021819516723d9169 (diff)
Merge remote-tracking branch 'origin/5.14' into 5.15
Diffstat (limited to 'sources/pyside2/PySide2/glue')
-rw-r--r--sources/pyside2/PySide2/glue/qtcore.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/sources/pyside2/PySide2/glue/qtcore.cpp b/sources/pyside2/PySide2/glue/qtcore.cpp
index 8bd2baac1..f941d5cfc 100644
--- a/sources/pyside2/PySide2/glue/qtcore.cpp
+++ b/sources/pyside2/PySide2/glue/qtcore.cpp
@@ -1984,3 +1984,31 @@ PyTuple_SET_ITEM(%out, 0, %CONVERTTOPYTHON[%INTYPE_0](%in.first));
PyTuple_SET_ITEM(%out, 1, %CONVERTTOPYTHON[%INTYPE_1](%in.second));
return %out;
// @snippet return-qpair
+
+// @snippet qthread_pthread_cleanup
+#ifdef Q_OS_UNIX
+# include <stdio.h>
+# include <pthread.h>
+static void qthread_pthread_cleanup(void *arg)
+{
+ // PYSIDE 1282: When terminating a thread using QThread::terminate()
+ // (pthread_cancel()), QThread::run() is aborted and the lock is released,
+ // but ~GilState() is still executed for some reason. Prevent it from
+ // releasing.
+ auto gil = reinterpret_cast<Shiboken::GilState *>(arg);
+ gil->abandon();
+}
+#endif // Q_OS_UNIX
+// @snippet qthread_pthread_cleanup
+
+// @snippet qthread_pthread_cleanup_install
+#ifdef Q_OS_UNIX
+pthread_cleanup_push(qthread_pthread_cleanup, &gil);
+#endif
+// @snippet qthread_pthread_cleanup_install
+
+// @snippet qthread_pthread_cleanup_uninstall
+#ifdef Q_OS_UNIX
+pthread_cleanup_pop(0);
+#endif
+// @snippet qthread_pthread_cleanup_uninstall