aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4sequenceobject.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-09-22 12:19:51 +0200
committerUlf Hermann <ulf.hermann@qt.io>2023-09-25 10:19:52 +0200
commit76987d262768783ea85e83d7f330e67f04af2ac3 (patch)
treeba2a056c5900ed628a0a89cb2b2654b86616c6ca /src/qml/jsruntime/qv4sequenceobject.cpp
parentc2031c6153c9625f63bb1091a79317885fae52e2 (diff)
QML: Silence warnings about converting holes in sparse arrays
Holes in sparse arrays are undefined when read via get(). QV4::Sequence does not have holes, by design. Therefore, when converting, we fill the holes with default-constructed values. This is on purpose and should not cause warnings. Furthermore, since QVariant::convert() always produces the given type, we don't need to re-initialize the variant afterwards. Change-Id: I46a675dfb71ae9f66858c97a580ec133aabef10e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/qml/jsruntime/qv4sequenceobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4sequenceobject.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp
index 13388108c4..775b90b637 100644
--- a/src/qml/jsruntime/qv4sequenceobject.cpp
+++ b/src/qml/jsruntime/qv4sequenceobject.cpp
@@ -714,14 +714,15 @@ QVariant SequencePrototype::toVariant(const QV4::Value &array, QMetaType typeHin
variant, valueMetaType);
if (converted.isValid()) {
variant = converted;
- } else if (!variant.convert(valueMetaType)) {
+ } else if (!variant.convert(valueMetaType) && originalType.isValid()) {
+ // If the original type was void, we're converting a "hole" in a sparse
+ // array. There is no point in warning about that.
qWarning().noquote()
<< QLatin1String("Could not convert array value "
"at position %1 from %2 to %3")
.arg(QString::number(i),
QString::fromUtf8(originalType.name()),
QString::fromUtf8(valueMetaType.name()));
- variant = QVariant(valueMetaType);
}
}
meta->addValueAtEnd(result.data(), variant.constData());