aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4engine.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/qv4engine.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/qv4engine.cpp')
-rw-r--r--src/qml/jsruntime/qv4engine.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index da0bfc2822..f6f4c5211a 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -1595,15 +1595,15 @@ static QVariant toVariant(
} else {
auto originalType = asVariant.metaType();
bool couldConvert = asVariant.convert(valueMetaType);
- if (!couldConvert) {
+ if (!couldConvert && 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()));
- // create default constructed value
- asVariant = QVariant(valueMetaType, nullptr);
}
retnAsIterable.metaContainer().addValue(retn.data(), asVariant.constData());
}