diff options
-rw-r--r-- | src/qml/compiler/qqmlcodegenerator.cpp | 6 | ||||
-rw-r--r-- | src/qml/qml/qqmlcompiler.cpp | 5 | ||||
-rw-r--r-- | tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp | 29 |
3 files changed, 35 insertions, 5 deletions
diff --git a/src/qml/compiler/qqmlcodegenerator.cpp b/src/qml/compiler/qqmlcodegenerator.cpp index ecb643e0f5..13b23fde68 100644 --- a/src/qml/compiler/qqmlcodegenerator.cpp +++ b/src/qml/compiler/qqmlcodegenerator.cpp @@ -1550,8 +1550,10 @@ V4IR::Expr *JSCodeGen::fallbackNameLookup(const QString &name, int line, int col V4IR::Temp *result = _block->TEMP(_block->newTemp()); _block->MOVE(result, s); result = _block->TEMP(result->index); - initMetaObjectResolver(&result->memberResolver, mapping.type); - result->memberResolver.flags |= AllPropertiesAreFinal; + if (mapping.type) { + initMetaObjectResolver(&result->memberResolver, mapping.type); + result->memberResolver.flags |= AllPropertiesAreFinal; + } result->isReadOnly = true; // don't allow use as lvalue return result; } diff --git a/src/qml/qml/qqmlcompiler.cpp b/src/qml/qml/qqmlcompiler.cpp index 2e208f2f3b..3dd9d6a14d 100644 --- a/src/qml/qml/qqmlcompiler.cpp +++ b/src/qml/qml/qqmlcompiler.cpp @@ -3711,7 +3711,10 @@ bool QQmlCompiler::completeComponentBuild() JSCodeGen::IdMapping m; m.name = o->id; m.idIndex = o->idIndex; - m.type = o->metatype; + if (output->types[o->type].isFullyDynamicType) + m.type = 0; + else + m.type = o->metatype; idMapping << m; } } diff --git a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp index 17f54508a3..62b64a3ef1 100644 --- a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp +++ b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp @@ -72,6 +72,7 @@ private slots: void QTBUG_29836(); void QTBUG_35233(); void disallowExtending(); + void QTBUG_35906(); }; class LazyPropertyMap : public QQmlPropertyMap, public QQmlParserStatus @@ -79,7 +80,7 @@ class LazyPropertyMap : public QQmlPropertyMap, public QQmlParserStatus Q_OBJECT Q_INTERFACES(QQmlParserStatus) - Q_PROPERTY(int someFixedProperty READ someFixedProperty WRITE setSomeFixedProperty) + Q_PROPERTY(int someFixedProperty READ someFixedProperty WRITE setSomeFixedProperty NOTIFY someFixedPropertyChanged) public: LazyPropertyMap() : QQmlPropertyMap(this, /*parent*/0) @@ -92,7 +93,10 @@ public: } int someFixedProperty() const { return value; } - void setSomeFixedProperty(int v) { value = v; } + void setSomeFixedProperty(int v) { value = v; emit someFixedPropertyChanged(); } + +signals: + void someFixedPropertyChanged(); private: int value; @@ -450,6 +454,27 @@ void tst_QQmlPropertyMap::disallowExtending() QCOMPARE(component.errors().at(0).toString(), QStringLiteral("<Unknown File>: Fully dynamic types cannot declare new properties.")); } +void tst_QQmlPropertyMap::QTBUG_35906() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import QtQml 2.0\n" + "import QTBUG_35233 1.0\n" + "QtObject {\n" + " property int testValue: mapById.someFixedProperty\n" + "\n" + " property QtObject maProperty: LazyPropertyMap {\n" + " id: mapById\n" + " someFixedProperty: 42\n" + " }\n" + "}\n", QUrl()); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + QVariant value = obj->property("testValue"); + QVERIFY(value.type() == QVariant::Int); + QCOMPARE(value.toInt(), 42); +} + QTEST_MAIN(tst_QQmlPropertyMap) #include "tst_qqmlpropertymap.moc" |