diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-06-30 10:24:34 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-06-30 15:09:14 +0000 |
commit | 14e60183a97838814ceed7240e0f8ba9a2ec67f5 (patch) | |
tree | 5f674284c771e0fc23c85803878492db4e16f164 /src/qmlmodels/qqmllistmodel.cpp | |
parent | 2fd54b5bef7dd2c8dd21ab7d2ff66145df1e4fa2 (diff) |
ListModel: Fix accessing empty strings in ListElement
We store empty strings as null strings in StringOrTranslation;
consequently isSet will return false for such a string. However, we
still know that we are storing a string, and therefore need to return
a QVariant containing an empty string, instead of a null QVariant.
Amends 5022b91b31370e2afde0426f94ff2ce6843b92e6.
This fixes the "undefined" warning in Calqlatr (but changes nothing
about the fact that the example isn't reflective of modern QML
practices).
Task-number: QTBUG-54267
Change-Id: I83d871a79cd2bc0484f0eaf62d4ca345e39218aa
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit 9be6a9327af1ac96bccca087ef24100d89a5f8c5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/qmlmodels/qqmllistmodel.cpp')
-rw-r--r-- | src/qmlmodels/qqmllistmodel.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/qmlmodels/qqmllistmodel.cpp b/src/qmlmodels/qqmllistmodel.cpp index d983d7f88e..a9c58d59a5 100644 --- a/src/qmlmodels/qqmllistmodel.cpp +++ b/src/qmlmodels/qqmllistmodel.cpp @@ -941,6 +941,8 @@ QVariant ListElement::getProperty(const ListLayout::Role &role, const QQmlListMo StringOrTranslation *value = reinterpret_cast<StringOrTranslation *>(mem); if (value->isSet()) data = value->toString(owner); + else + data = QString(); } break; case ListLayout::Role::Bool: |