Fix crash in QgsStringUtils::truncateMiddleOfString on qt 6

This commit is contained in:
Nyall Dawson 2024-02-15 09:49:37 +10:00
parent 4087dc411a
commit 1662500478
2 changed files with 2 additions and 1 deletions

View File

@ -69,7 +69,6 @@ PyQgsTextRenderer
PyQgsOGRProvider
PyQgsSpatialiteProvider
PyQgsSymbolLayerReadSld
PyQgsStringUtils
PyQgsTextDocument
PyQgsVectorLayerCache
PyQgsVectorLayerEditBuffer

View File

@ -735,6 +735,8 @@ QString QgsStringUtils::truncateMiddleOfString( const QString &string, int maxLe
// note we actually truncate an extra character, as we'll be replacing it with the ... character
const int truncateFrom = string.length() / 2 - ( charactersToTruncate + 1 ) / 2;
if ( truncateFrom == 0 || charactersToTruncate >= string.length() )
return QChar( 0x2026 );
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return string.leftRef( truncateFrom ) + QString( QChar( 0x2026 ) ) + string.midRef( truncateFrom + charactersToTruncate + 1 );