From 3fad864a4bbeafa1714f6b7876172bdee075b2f3 Mon Sep 17 00:00:00 2001 From: bdm-oslandia Date: Thu, 15 May 2025 14:40:06 +0200 Subject: [PATCH 1/2] fix: make qgsVariantCompare for QString the same between qt5 and qt6 qt5 return -1, 0, 1 where qt6 returns the lexical distance between the 2 strings. --- src/core/qgis.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/qgis.cpp b/src/core/qgis.cpp index 47f334ea81a..b4f2fa26040 100644 --- a/src/core/qgis.cpp +++ b/src/core/qgis.cpp @@ -279,7 +279,7 @@ int qgsVariantCompare( const QVariant &lhs, const QVariant &rhs ) } default: - return QString::localeAwareCompare( lhs.toString(), rhs.toString() ); + return std::clamp( QString::localeAwareCompare( lhs.toString(), rhs.toString() ), -1, 1 ); } } From 3b2cbca49b0a7649d78dc92783f933be3d8871c6 Mon Sep 17 00:00:00 2001 From: bdm-oslandia Date: Fri, 16 May 2025 08:53:48 +0200 Subject: [PATCH 2/2] tests: adapt QgsFlagKeysToValue to qt6 With qt6 `metaEnum.valueToKeys( -1 );` failed by returning "" instead of some default ("HideReadOnly|OriginProvider|AllTypes") --- src/core/qgis.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/qgis.h b/src/core/qgis.h index a4df0fa708e..325092f3f72 100644 --- a/src/core/qgis.h +++ b/src/core/qgis.h @@ -6601,9 +6601,9 @@ template T qgsFlagKeysToValue( const QString &keys, const T &defaultVal const int intValue = keys.toInt( &canConvert ); if ( canConvert ) { - const QByteArray keys = metaEnum.valueToKeys( intValue ); - const int intValueCheck = metaEnum.keysToValue( keys ); - if ( intValue == intValueCheck ) + const QByteArray keyArray = metaEnum.valueToKeys( intValue ); + const int intValueCheck = metaEnum.keysToValue( keyArray ); + if ( !keyArray.isEmpty() && intValue == intValueCheck ) { if ( returnOk ) {