diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-12-19 09:24:49 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-01-05 21:29:27 +0100 |
commit | afba8e4a28d92c8584f2faa233372dd69887031c (patch) | |
tree | 3b46c79ebf40c2b1a86865b7c82e734632d701fd /sources/pyside6/PySide6/QtCore/typesystem_core_common.xml | |
parent | a8fcf44147167e186a1c7da7488ab821cc041291 (diff) |
Fix qCompress/qUncompress() taking a PyBuffer/len arguments
The overloads taking a uchar * data argument were generated using the
converter for uchar, causing warnings:
qbytearray.h:639: There's no user provided way (conversion rule, argument removal, custom code, etc) to handle the primitive type 'const uchar *' of argument 1 in function 'qCompress(const uchar * data, qsizetype nbytes, int compressionLevel)'.
qbytearray.h:640: There's no user provided way (conversion rule, argument removal, custom code, etc) to handle the primitive type 'const uchar *' of argument 1 in function 'qUncompress(const uchar * data, qsizetype nbytes)'.
This was never noticed since we have a conversion from PyBuffer
to QByteArray and the overload decisor checks only whether the minimum
argument is satifisfied, so, so qCompress(data,len,level) it called
qCompress(bytearry,len), passing the length as level.
To fix this, modify the argument to PyBuffer as is done for QImage and
give it overload-number 0, so that PyBuffer is checked first without
conversion to QByteArray. Add a test for both cases.
Amends ae51319fa8a7c02642f5d35f5d613c22e9ce8ecb.
Task-number: PYSIDE-838
Change-Id: Ib9b22a24257fcf93ce3458d8514cdda2e4843f64
Reviewed-by: Christian Tismer <tismer@stackless.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'sources/pyside6/PySide6/QtCore/typesystem_core_common.xml')
-rw-r--r-- | sources/pyside6/PySide6/QtCore/typesystem_core_common.xml | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml index e7c85fc55..dbf93a871 100644 --- a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml +++ b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml @@ -36,10 +36,26 @@ <modify-argument index="return" pyi-type="str"/> </modify-function> </function> - <function signature="qCompress(const uchar*,qsizetype,int)"/> - <function signature="qCompress(const QByteArray&,int)"/> - <function signature="qUncompress(const uchar*,qsizetype)" doc-file="qbytearray"/> - <function signature="qUncompress(const QByteArray&)" doc-file="qbytearray"/> + <!-- Move PyBuffer overload to front to avoid conversion PyBuffer->QByteArray --> + <function signature="qCompress(const uchar*,qsizetype,int)" overload-number="0"> + <modify-function> + <modify-argument index="1"> + <replace-type modified-type="PyBuffer"/> + </modify-argument> + <inject-code file="../glue/qtcore.cpp" snippet="qcompress-buffer"/> + </modify-function> + </function> + <function signature="qCompress(const QByteArray&,int)" overload-number="1"/> + <!-- Move PyBuffer overload to front to avoid conversion PyBuffer->QByteArray --> + <function signature="qUncompress(const uchar*,qsizetype)" overload-number="0"> + <modify-function> + <modify-argument index="1"> + <replace-type modified-type="PyBuffer"/> + </modify-argument> + <inject-code file="../glue/qtcore.cpp" snippet="quncompress-buffer"/> + </modify-function> + </function> + <function signature="qUncompress(const QByteArray&)" overload-number="1"/> <function signature="qFormatLogMessage(QtMsgType,const QMessageLogContext&,const QString&)" doc-file="qtlogging"/> <function signature="qSetMessagePattern(const QString&)" doc-file="qtlogging"/> |