diff options
author | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2022-06-03 10:48:50 +0200 |
---|---|---|
committer | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2022-06-15 19:49:46 +0200 |
commit | 20eb4f94c637d20461f1fef16942841803ada909 (patch) | |
tree | a36abc1889d93809d1f35206c3da8cec0f1d0ff5 /sources | |
parent | 4131e4549108bc53149a45b24ccc5b3a40b6cf60 (diff) |
pyside: Modify QAbstractListModel.data(..) to consider enums
- The function under consideration returns a QVariant, which is used
internally within the C++ code. Sometimes, the value stored in this
QVariant can also be a Python enum/Shiboken enum. When such a case
occurs, the returned QVariant to the C++ side is a QVariant of Python
/Shiboken enum, which cannot be processed from C++ code.
- This is a regression from 108d82d2ca5323652a50706b37f829b9f0457367
which needs some special handling.
- The solution is the convert the python enum (Shiboken enum) to the
corresponding integer type, which is stored into the QVariant and
returned to the C++ side.
Pick-to: 6.3
Fixes: PYSIDE-1930
Change-Id: Id4e9a1caa5a318e2410e584502c6dc6e35e3a657
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources')
-rw-r--r-- | sources/pyside6/PySide6/QtCore/typesystem_core_common.xml | 3 | ||||
-rw-r--r-- | sources/pyside6/PySide6/glue/qtcore.cpp | 11 |
2 files changed, 14 insertions, 0 deletions
diff --git a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml index 876e226e9..514ede340 100644 --- a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml +++ b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml @@ -1767,6 +1767,9 @@ <include file-name="QStringList" location="global"/> <include file-name="QSize" location="global"/> </extra-includes> + <modify-function signature="data(const QModelIndex&,int)const"> + <inject-code class="native" position="end" file="../glue/qtcore.cpp" snippet="qabstractitemmodel_data"/> + </modify-function> </object-type> <value-type name="QUrlQuery" since="5.0"/> diff --git a/sources/pyside6/PySide6/glue/qtcore.cpp b/sources/pyside6/PySide6/glue/qtcore.cpp index 4bca53182..ec9d70285 100644 --- a/sources/pyside6/PySide6/glue/qtcore.cpp +++ b/sources/pyside6/PySide6/glue/qtcore.cpp @@ -1700,3 +1700,14 @@ static PyObject *invokeMethodHelper(QObject *obj, const char *member, Qt::Connec %PYARG_0 = invokeMethodHelper(%1, %2, Qt::AutoConnection, %3, %4, %5, %6); // @snippet qmetaobject-invokemethod-return-arg +// @snippet qabstractitemmodel_data +::QVariant %0 ; +if (Shiboken::Enum::check(%PYARG_0)) { + int in = %CONVERTTOCPP[int](%PYARG_0); + %0 = QVariant(in); +} +else +{ + pythonToCpp(pyResult, &cppResult); +} +// @snippet qabstractitemmodel_data |