Leave null QByteArray values as QByteArray() to maintain API

These should probably be returned as None or NULL for consistency,
but let's not break API right now...
This commit is contained in:
Nyall Dawson 2024-06-12 20:34:18 +10:00
parent fb30022bca
commit f23caeef50
3 changed files with 16 additions and 8 deletions

View File

@ -53,7 +53,8 @@ geometry and a list of field/values attributes.
else
{
const QVariant v = sipCpp->attribute( a0 );
if ( QgsVariantUtils::isNull( v, true ) )
// QByteArray null handling is "special"! See null_from_qvariant_converter in conversions.sip
if ( QgsVariantUtils::isNull( v, true ) && v.userType() != QMetaType::Type::QByteArray )
{
Py_INCREF( Py_None );
sipRes = Py_None;
@ -115,7 +116,8 @@ geometry and a list of field/values attributes.
else
{
const QVariant v = sipCpp->attribute( fieldIdx );
if ( QgsVariantUtils::isNull( v, true ) )
// QByteArray null handling is "special"! See null_from_qvariant_converter in conversions.sip
if ( QgsVariantUtils::isNull( v, true ) && v.userType() != QMetaType::Type::QByteArray )
{
Py_INCREF( Py_None );
sipRes = Py_None;

View File

@ -57,7 +57,8 @@ geometry and a list of field/values attributes.
Py_INCREF( Py_None );
sipRes = Py_None;
}
else if ( QgsVariantUtils::isNull( v, true ) )
// QByteArray null handling is "special"! See null_from_qvariant_converter in conversions.sip
else if ( QgsVariantUtils::isNull( v, true ) && v.userType() != QMetaType::Type::QByteArray )
{
PyObject *vartype = sipConvertFromEnum( v.type(), sipType_QVariant_Type );
PyObject *args = PyTuple_Pack( 1, vartype );
@ -128,7 +129,8 @@ geometry and a list of field/values attributes.
Py_INCREF( Py_None );
sipRes = Py_None;
}
else if ( QgsVariantUtils::isNull( v, true ) )
// QByteArray null handling is "special"! See null_from_qvariant_converter in conversions.sip
else if ( QgsVariantUtils::isNull( v, true ) && v.userType() != QMetaType::Type::QByteArray )
{
PyObject *vartype = sipConvertFromEnum( v.type(), sipType_QVariant_Type );
PyObject *args = PyTuple_Pack( 1, vartype );

View File

@ -96,7 +96,8 @@ class CORE_EXPORT QgsFeature
Py_INCREF( Py_None );
sipRes = Py_None;
}
else if ( QgsVariantUtils::isNull( v, true ) )
// QByteArray null handling is "special"! See null_from_qvariant_converter in conversions.sip
else if ( QgsVariantUtils::isNull( v, true ) && v.userType() != QMetaType::Type::QByteArray )
{
PyObject *vartype = sipConvertFromEnum( v.type(), sipType_QVariant_Type );
PyObject *args = PyTuple_Pack( 1, vartype );
@ -167,7 +168,8 @@ class CORE_EXPORT QgsFeature
Py_INCREF( Py_None );
sipRes = Py_None;
}
else if ( QgsVariantUtils::isNull( v, true ) )
// QByteArray null handling is "special"! See null_from_qvariant_converter in conversions.sip
else if ( QgsVariantUtils::isNull( v, true ) && v.userType() != QMetaType::Type::QByteArray )
{
PyObject *vartype = sipConvertFromEnum( v.type(), sipType_QVariant_Type );
PyObject *args = PyTuple_Pack( 1, vartype );
@ -236,7 +238,8 @@ class CORE_EXPORT QgsFeature
else
{
const QVariant v = sipCpp->attribute( a0 );
if ( QgsVariantUtils::isNull( v, true ) )
// QByteArray null handling is "special"! See null_from_qvariant_converter in conversions.sip
if ( QgsVariantUtils::isNull( v, true ) && v.userType() != QMetaType::Type::QByteArray )
{
Py_INCREF( Py_None );
sipRes = Py_None;
@ -298,7 +301,8 @@ class CORE_EXPORT QgsFeature
else
{
const QVariant v = sipCpp->attribute( fieldIdx );
if ( QgsVariantUtils::isNull( v, true ) )
// QByteArray null handling is "special"! See null_from_qvariant_converter in conversions.sip
if ( QgsVariantUtils::isNull( v, true ) && v.userType() != QMetaType::Type::QByteArray )
{
Py_INCREF( Py_None );
sipRes = Py_None;