diff options
author | Clemens Sielaff <git@clemens-sielaff.com> | 2016-07-24 11:21:34 +1200 |
---|---|---|
committer | Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com> | 2016-08-03 11:16:35 +0000 |
commit | 2a24c3c268d443fb260d731d9f65b57726a40354 (patch) | |
tree | 79edca5f870869a2f22fd634242ed948ae157208 /src | |
parent | dbb5c95f4d80644c6273b3adbe0148cdf30710d2 (diff) |
Fixed Bug in QVariant comparison when containing QStringLists
As it were, QStringLists were not handled explicitly when comparing
QVariants. If both QStringLists contained only a single entry, they
were treated as QStrings - if both QStringLists were empty, there were
equal (correctly so) - but if one of the QStringLists had more than
one entry, the compare function fell through to returning always 1.
As discussed here: https://stackoverflow.com/a/38492467/3444217
Added rich comparison tests for all non-numerical, non-recursive
QVariants that support them (except QModelIndex and
QPersistentModelIndex)
Task-number: QTBUG-54893
Change-Id: Icc5480d9ba056ee5efe83da566c5829caa1509d7
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qvariant.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 7596699843..4f256cccda 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -3560,6 +3560,8 @@ int QVariant::compare(const QVariant &v) const return v1.toTime() < v2.toTime() ? -1 : 1; case QVariant::DateTime: return v1.toDateTime() < v2.toDateTime() ? -1 : 1; + case QVariant::StringList: + return v1.toStringList() < v2.toStringList() ? -1 : 1; } int r = v1.toString().compare(v2.toString(), Qt::CaseInsensitive); if (r == 0) { |