mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2025-12-11 00:07:51 +03:00
88 lines
3.2 KiB
Diff
88 lines
3.2 KiB
Diff
https://bugreports.qt.io/browse/QTBUG-139626
|
|
https://codereview.qt-project.org/c/qt/qtdeclarative/+/672607
|
|
--- a/src/qmlcompiler/qqmljscodegenerator.cpp
|
|
+++ b/src/qmlcompiler/qqmljscodegenerator.cpp
|
|
@@ -1441,4 +1441,15 @@
|
|
}
|
|
|
|
+QString QQmlJSCodeGenerator::generateVariantMapLookup(
|
|
+ const QString &map, const int nameIndex)
|
|
+{
|
|
+ const QString mapLookup = map
|
|
+ + u"["_s + QQmlJSUtils::toLiteral(m_jsUnitGenerator->lookupName(nameIndex)) + u"]"_s;
|
|
+
|
|
+ return m_state.accumulatorVariableOut + u" = "_s
|
|
+ + conversion(m_typeResolver->varType(), m_state.accumulatorOut(), mapLookup)
|
|
+ + u";\n"_s;
|
|
+}
|
|
+
|
|
void QQmlJSCodeGenerator::generate_GetLookupHelper(int index)
|
|
{
|
|
@@ -1588,9 +1599,5 @@
|
|
}
|
|
} else if (accumulatorIn.isStoredIn(m_typeResolver->variantMapType())) {
|
|
- QString mapLookup = m_state.accumulatorVariableIn + u"["_s
|
|
- + QQmlJSUtils::toLiteral(m_jsUnitGenerator->lookupName(index)) + u"]"_s;
|
|
- m_body += m_state.accumulatorVariableOut + u" = "_s;
|
|
- m_body += conversion(m_typeResolver->varType(), m_state.accumulatorOut(), mapLookup);
|
|
- m_body += u";\n"_s;
|
|
+ m_body += generateVariantMapLookup(m_state.accumulatorVariableIn, index);
|
|
} else {
|
|
if (m_state.isRegisterAffectedBySideEffects(Accumulator))
|
|
@@ -1602,4 +1609,11 @@
|
|
m_jsUnitGenerator->lookupName(index)));
|
|
|
|
+ if (scope.contains(m_typeResolver->variantMapType())) {
|
|
+ m_body += generateVariantMapLookup(
|
|
+ u"(*static_cast<const QVariantMap *>("_s
|
|
+ + inputContentPointer + u"))"_s, index);
|
|
+ return;
|
|
+ }
|
|
+
|
|
const QString lookup = u"aotContext->getValueLookup("_s + indexString
|
|
+ u", "_s + inputContentPointer
|
|
--- a/src/qmlcompiler/qqmljscodegenerator_p.h
|
|
+++ b/src/qmlcompiler/qqmljscodegenerator_p.h
|
|
@@ -360,4 +360,6 @@
|
|
const QStringList &arguments, const QString &metaType, const QString &metaObject);
|
|
|
|
+ QString generateVariantMapLookup(const QString &map, const int nameIndex);
|
|
+
|
|
QQmlJSRegisterContent originalType(QQmlJSRegisterContent tracked)
|
|
{
|
|
--- a/tests/auto/qml/qmlcppcodegen/data/variantMapLookup.h
|
|
+++ b/tests/auto/qml/qmlcppcodegen/data/variantMapLookup.h
|
|
@@ -9,4 +9,5 @@
|
|
QML_ELEMENT
|
|
Q_PROPERTY(QVariantMap data READ data CONSTANT)
|
|
+ Q_PROPERTY(QList<QVariantMap> many READ many CONSTANT)
|
|
|
|
public:
|
|
@@ -15,3 +16,10 @@
|
|
private:
|
|
QVariantMap data() const { return { { QStringLiteral("value"), 42 } }; }
|
|
+ QList<QVariantMap> many() const
|
|
+ {
|
|
+ const QVariantMap one = data();
|
|
+ return QList<QVariantMap>({one, one, one});
|
|
+ }
|
|
};
|
|
+
|
|
+
|
|
--- a/tests/auto/qml/qmlcppcodegen/data/variantMapLookup.qml
|
|
+++ b/tests/auto/qml/qmlcppcodegen/data/variantMapLookup.qml
|
|
@@ -5,4 +5,5 @@
|
|
Item {
|
|
property int i: moo.data.value
|
|
+ property int j: moo.many[1].value
|
|
|
|
VariantMapLookupFoo {
|
|
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
|
|
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
|
|
@@ -5697,4 +5697,5 @@
|
|
QVERIFY(!o.isNull());
|
|
QCOMPARE(o->property("i"), 42);
|
|
+ QCOMPARE(o->property("j"), 42);
|
|
}
|
|
|