Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
4.5.3, 4.6.2
-
None
-
cd003bfcf9a05967893099e8948ba3d8f281aa7d
Description
If you do a case-sensitive comparison of a QStringRef and a QLatin1String, the comparison returns a value other than 0, even if the strings are equal.
A comparison of QStrings works fine, because the character after the last character is '\0'
QString string = QLatin1String("ThisIsATestString");
QStringRef ref( &string, 0, 11 );
// returns 83 ('S')
ref.compare( QLatin1String("ThisIsATest") );
// returns 0
ref.compare( QLatin1String("ThisIsATestS") );
The problem lies within QString::compare_helper(const QChar *data1, int length1, QLatin1String s2, Qt::CaseSensitivity cs)
It would probably work, if the number of compared characters was reduced by 1 (const ushort *e = uc + length1 - 1, unless the comparison of the zero-character is mandatory for some cases.