aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/PySide2/glue/qtgui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside2/PySide2/glue/qtgui.cpp')
-rw-r--r--sources/pyside2/PySide2/glue/qtgui.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/sources/pyside2/PySide2/glue/qtgui.cpp b/sources/pyside2/PySide2/glue/qtgui.cpp
index 1c74c73d2..00d045787 100644
--- a/sources/pyside2/PySide2/glue/qtgui.cpp
+++ b/sources/pyside2/PySide2/glue/qtgui.cpp
@@ -190,6 +190,16 @@ for (int i = 0, i_max = %CPPSELF.count(); i < i_max; ++i){
%0 = new %TYPE(QPixmap::fromImage(%1));
// @snippet qpixmap
+// @snippet qimage-decref-image-data
+static void imageDecrefDataHandler(void *data)
+{
+ // Avoid "Python memory allocator called without holding the GIL"
+ auto state = PyGILState_Ensure();
+ Py_DECREF(reinterpret_cast<PyObject *>(data));
+ PyGILState_Release(state);
+}
+// @snippet qimage-decref-image-data
+
// @snippet qimage-constbits
%PYARG_0 = Shiboken::Buffer::newObject(%CPPSELF.%FUNCTION_NAME(), %CPPSELF.byteCount());
// @snippet qimage-constbits