diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-05-13 19:40:40 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-05-14 16:43:39 +0000 |
commit | 9a1df2acfeb6ca970b97151cadbf2068b594f8cf (patch) | |
tree | c58068b55f3a64977eb7daef5e74de9036825d4a | |
parent | 8e51cc26656c834877dd16fbf2c8668e77f33b52 (diff) |
QQmlListAccessor: Store integer if m_type is Integer
When we pass a QVariant to QQmlListAccessor::setList which contains
something convertible to a number, we set the type to Integer. Later, we
simply return whatever is stored internally in the variant, and cast it
into an int. That goes horribly wrong if the variant actually contains a
floating point number.
To fix this, we now store the actual integer in the variant after the
checks are done.
Change-Id: I3aa173a1558e95361bb4b19e97542d8a435a6dd7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit 42afb8249cfcf8cec66aac9e55d13ac508699ec8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/qmlmodels/qqmllistaccessor.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/qmlmodels/qqmllistaccessor.cpp b/src/qmlmodels/qqmllistaccessor.cpp index 7412dd0146..ea336138ce 100644 --- a/src/qmlmodels/qqmllistaccessor.cpp +++ b/src/qmlmodels/qqmllistaccessor.cpp @@ -105,6 +105,7 @@ void QQmlListAccessor::setList(const QVariant &v, QQmlEngine *engine) m_type = Invalid; } else { m_type = Integer; + d = i; } } else if ((!enginePrivate && QQmlMetaType::isQObject(d.userType())) || (enginePrivate && enginePrivate->isQObject(d.userType()))) { |