diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2023-05-15 09:58:15 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-05-15 10:46:27 +0200 |
commit | e6dd62ff191de0276d2dee5d6b1a073b4d63c4cb (patch) | |
tree | 8c49e0ee9f548ecf11ceb7d30098faa092189839 | |
parent | ce85cb16160394d616bc3dc4bf2a8915ec63b036 (diff) | |
download | qtdeclarative-e6dd62ff191de0276d2dee5d6b1a073b4d63c4cb.tar.gz |
QmlCompiler: Do check specificType on SetLookup
We may have implicitly invalidated it when shadow-checking.
Amends commit b3281f123ea5a8c0e5f8c63fa1568cf7414f9c14.
Change-Id: Ia5c54a3a0fa97c61e947ecb0a5b21d410e1bf19a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r-- | src/qmlcompiler/qqmljscodegenerator.cpp | 9 | ||||
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/failures.qml | 5 | ||||
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/person.cpp | 13 | ||||
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/person.h | 8 |
4 files changed, 33 insertions, 2 deletions
diff --git a/src/qmlcompiler/qqmljscodegenerator.cpp b/src/qmlcompiler/qqmljscodegenerator.cpp index 810ed90cc9..d3770cc512 100644 --- a/src/qmlcompiler/qqmljscodegenerator.cpp +++ b/src/qmlcompiler/qqmljscodegenerator.cpp @@ -1186,8 +1186,13 @@ void QQmlJSCodeGenerator::generate_SetLookup(int index, int baseReg) const QQmlJSRegisterContent specific = m_typeResolver->memberType( callBase, m_jsUnitGenerator->lookupName(index)); - // We have checked that in the type propagator. - Q_ASSERT(!specific.storedType().isNull()); + if (specific.storedType().isNull()) { + reject(u"SetLookup. Could not find property " + + m_jsUnitGenerator->lookupName(index) + + u" on type " + + callBase.storedType()->internalName()); + return; + } // Choose a container that can hold both, the "in" accumulator and what we actually want. // If the types are all the same because we can all store them as verbatim C++ types, diff --git a/tests/auto/qml/qmlcppcodegen/data/failures.qml b/tests/auto/qml/qmlcppcodegen/data/failures.qml index e6f3af5e87..f0dff85301 100644 --- a/tests/auto/qml/qmlcppcodegen/data/failures.qml +++ b/tests/auto/qml/qmlcppcodegen/data/failures.qml @@ -83,6 +83,11 @@ QtObject { return a; } + property Person shadowable + function setLookupOnShadowable() { + shadowable.area.width = 16 + } + // TODO: Drop these once we can manipulate QVariant-wrapped lists. property list<withLength> withLengths property int l: withLengths.length diff --git a/tests/auto/qml/qmlcppcodegen/data/person.cpp b/tests/auto/qml/qmlcppcodegen/data/person.cpp index 4dcd6fd56f..f6353d9b67 100644 --- a/tests/auto/qml/qmlcppcodegen/data/person.cpp +++ b/tests/auto/qml/qmlcppcodegen/data/person.cpp @@ -98,3 +98,16 @@ void Person::setCousins(const QList<Person *> &newCousins) m_cousins = newCousins; emit cousinsChanged(); } + +QRectF Person::area() const +{ + return m_area; +} + +void Person::setArea(const QRectF &newArea) +{ + if (m_area == newArea) + return; + m_area = newArea; + emit areaChanged(); +} diff --git a/tests/auto/qml/qmlcppcodegen/data/person.h b/tests/auto/qml/qmlcppcodegen/data/person.h index b30b7e024b..2f3b28eb66 100644 --- a/tests/auto/qml/qmlcppcodegen/data/person.h +++ b/tests/auto/qml/qmlcppcodegen/data/person.h @@ -8,6 +8,7 @@ #include <QtQml/qqml.h> #include <QtQml/qqmlengine.h> #include <QtCore/qproperty.h> +#include <QtCore/qrect.h> // Intentionally opaque type class Barzle : public QObject {}; @@ -22,6 +23,7 @@ class Person : public QObject Q_PROPERTY(QList<Barzle *> barzles READ barzles WRITE setBarzles NOTIFY barzlesChanged FINAL) Q_PROPERTY(QList<Person *> cousins READ cousins WRITE setCousins NOTIFY cousinsChanged FINAL) Q_PROPERTY(QByteArray data READ data WRITE setData NOTIFY dataChanged FINAL) + Q_PROPERTY(QRectF area READ area WRITE setArea NOTIFY areaChanged) // not FINAL QML_ELEMENT public: Person(QObject *parent = nullptr); @@ -52,6 +54,9 @@ public: QList<Person *> cousins() const; void setCousins(const QList<Person *> &newCousins); + QRectF area() const; + void setArea(const QRectF &newArea); + signals: void nameChanged(); void shoeSizeChanged(); @@ -65,6 +70,8 @@ signals: void objectListHappened(const QList<QObject *> &); void variantListHappened(const QList<QVariant> &); + void areaChanged(); + private: QString m_name; int m_shoeSize; @@ -72,6 +79,7 @@ private: QList<Barzle *> m_barzles; QList<Person *> m_cousins; QProperty<QByteArray> m_data; + QRectF m_area; }; class BarzleListRegistration |