diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-05-25 11:24:21 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-05-25 12:03:39 +0200 |
| commit | 7079bc4ffc63dd42054014b4b78bff78abed962b (patch) | |
| tree | 85b96c0772adef61ac7349eceec32cfcd31739d7 /sources/pyside6/PySide6/glue/qtgui.cpp | |
| parent | 4daaa2edd881865172f19c007c69113bf4afc8cd (diff) | |
Fix crashes when using the QImage(uchar *) data constructors, take 2
The constructors expect a range of memory that remains valid
through the lifetime of the image and may also modify it.
Crashes occurred since apparently the Py_Buffer was released before
it.
To fix this, inject code to increase the reference count
and decrease it in the cleanup function.
Pick-to: 6.1 5.15
Fixes: PYSIDE-1563
Change-Id: Ic4a47e0f458ed5b59b88813139102a9f1490a9df
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside6/PySide6/glue/qtgui.cpp')
| -rw-r--r-- | sources/pyside6/PySide6/glue/qtgui.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/sources/pyside6/PySide6/glue/qtgui.cpp b/sources/pyside6/PySide6/glue/qtgui.cpp index 48d246ddc..681539c97 100644 --- a/sources/pyside6/PySide6/glue/qtgui.cpp +++ b/sources/pyside6/PySide6/glue/qtgui.cpp @@ -160,6 +160,13 @@ for (Py_ssize_t i = 0; i < count; ++i){ %0 = new %TYPE(QPixmap::fromImage(%1)); // @snippet qpixmap +// @snippet qimage-decref-image-data +static void imageDecrefDataHandler(void *data) +{ + Py_DECREF(reinterpret_cast<PyObject *>(data)); +} +// @snippet qimage-decref-image-data + // @snippet qimage-constbits %PYARG_0 = Shiboken::Buffer::newObject(%CPPSELF.%FUNCTION_NAME(), %CPPSELF.sizeInBytes()); // @snippet qimage-constbits |
