diff options
| author | Cristián Maureira-Fredes <cristian.maureira-fredes@qt.io> | 2024-11-07 09:36:21 +0100 |
|---|---|---|
| committer | Cristián Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2024-11-08 08:33:38 +0100 |
| commit | fb13a26a76eba415e743d119d5d2782c607fee2f (patch) | |
| tree | 1547b255a7e4afa4e328549d0e613e5b25a45b84 /sources/pyside6/PySide6/glue/qtgui.cpp | |
| parent | 2b1dbe1b6610027dbf5f521ae9c7b56f3a343160 (diff) | |
limited api: replace PySequence_Fast_GET_ITEM by PySequence_GetItem
PySequence_Fast_GET_ITEM is defined as:
(PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
and when using the Limited API we re-define the _GET_ITEM macro
to be the _GetItem function, and considering this is our standard
use case, the macro could be replaced directly by the function.
However, the function returns a new reference, so we need to manually
drecrease a reference after the usage, to avoid reference counting
issues.
Change-Id: If361e80b9e40b033e009ad46b2b9430e5b4c8eaa
Pick-to: 6.8
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside6/PySide6/glue/qtgui.cpp')
| -rw-r--r-- | sources/pyside6/PySide6/glue/qtgui.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sources/pyside6/PySide6/glue/qtgui.cpp b/sources/pyside6/PySide6/glue/qtgui.cpp index aacac3508..428840898 100644 --- a/sources/pyside6/PySide6/glue/qtgui.cpp +++ b/sources/pyside6/PySide6/glue/qtgui.cpp @@ -716,7 +716,7 @@ Shiboken::AutoDecRef seq(PySequence_Fast(%PYARG_1, "Can't turn into sequence")); if (PySequence_Size(seq) == 16) { float values[16]; for (Py_ssize_t i = 0; i < 16; ++i) { - PyObject *pv = PySequence_Fast_GET_ITEM(seq.object(), i); + Shiboken::AutoDecRef pv(PySequence_GetItem(seq.object(), i)); values[i] = PyFloat_AsDouble(pv); } @@ -741,8 +741,8 @@ for (Py_ssize_t i = 0; i < 16; ++i) { if (PySequence_Check(_key)) { Shiboken::AutoDecRef key(PySequence_Fast(_key, "Invalid matrix index.")); if (PySequence_Fast_GET_SIZE(key.object()) == 2) { - PyObject *posx = PySequence_Fast_GET_ITEM(key.object(), 0); - PyObject *posy = PySequence_Fast_GET_ITEM(key.object(), 1); + Shiboken::AutoDecRef posx(PySequence_GetItem(key.object(), 0)); + Shiboken::AutoDecRef posy(PySequence_GetItem(key.object(), 1)); Py_ssize_t x = PyLong_AsSsize_t(posx); Py_ssize_t y = PyLong_AsSsize_t(posy); float ret = (*%CPPSELF)(x,y); |
