Skip to content

Commit e6dd62f

Browse files
committed
QmlCompiler: Do check specificType on SetLookup
We may have implicitly invalidated it when shadow-checking. Amends commit b3281f1. Change-Id: Ia5c54a3a0fa97c61e947ecb0a5b21d410e1bf19a Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Volker Hilsheimer <[email protected]>
1 parent ce85cb1 commit e6dd62f

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

src/qmlcompiler/qqmljscodegenerator.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,8 +1186,13 @@ void QQmlJSCodeGenerator::generate_SetLookup(int index, int baseReg)
11861186
const QQmlJSRegisterContent specific = m_typeResolver->memberType(
11871187
callBase, m_jsUnitGenerator->lookupName(index));
11881188

1189-
// We have checked that in the type propagator.
1190-
Q_ASSERT(!specific.storedType().isNull());
1189+
if (specific.storedType().isNull()) {
1190+
reject(u"SetLookup. Could not find property "
1191+
+ m_jsUnitGenerator->lookupName(index)
1192+
+ u" on type "
1193+
+ callBase.storedType()->internalName());
1194+
return;
1195+
}
11911196

11921197
// Choose a container that can hold both, the "in" accumulator and what we actually want.
11931198
// If the types are all the same because we can all store them as verbatim C++ types,

tests/auto/qml/qmlcppcodegen/data/failures.qml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ QtObject {
8383
return a;
8484
}
8585

86+
property Person shadowable
87+
function setLookupOnShadowable() {
88+
shadowable.area.width = 16
89+
}
90+
8691
// TODO: Drop these once we can manipulate QVariant-wrapped lists.
8792
property list<withLength> withLengths
8893
property int l: withLengths.length

tests/auto/qml/qmlcppcodegen/data/person.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,16 @@ void Person::setCousins(const QList<Person *> &newCousins)
9898
m_cousins = newCousins;
9999
emit cousinsChanged();
100100
}
101+
102+
QRectF Person::area() const
103+
{
104+
return m_area;
105+
}
106+
107+
void Person::setArea(const QRectF &newArea)
108+
{
109+
if (m_area == newArea)
110+
return;
111+
m_area = newArea;
112+
emit areaChanged();
113+
}

tests/auto/qml/qmlcppcodegen/data/person.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <QtQml/qqml.h>
99
#include <QtQml/qqmlengine.h>
1010
#include <QtCore/qproperty.h>
11+
#include <QtCore/qrect.h>
1112

1213
// Intentionally opaque type
1314
class Barzle : public QObject {};
@@ -22,6 +23,7 @@ class Person : public QObject
2223
Q_PROPERTY(QList<Barzle *> barzles READ barzles WRITE setBarzles NOTIFY barzlesChanged FINAL)
2324
Q_PROPERTY(QList<Person *> cousins READ cousins WRITE setCousins NOTIFY cousinsChanged FINAL)
2425
Q_PROPERTY(QByteArray data READ data WRITE setData NOTIFY dataChanged FINAL)
26+
Q_PROPERTY(QRectF area READ area WRITE setArea NOTIFY areaChanged) // not FINAL
2527
QML_ELEMENT
2628
public:
2729
Person(QObject *parent = nullptr);
@@ -52,6 +54,9 @@ class Person : public QObject
5254
QList<Person *> cousins() const;
5355
void setCousins(const QList<Person *> &newCousins);
5456

57+
QRectF area() const;
58+
void setArea(const QRectF &newArea);
59+
5560
signals:
5661
void nameChanged();
5762
void shoeSizeChanged();
@@ -65,13 +70,16 @@ class Person : public QObject
6570
void objectListHappened(const QList<QObject *> &);
6671
void variantListHappened(const QList<QVariant> &);
6772

73+
void areaChanged();
74+
6875
private:
6976
QString m_name;
7077
int m_shoeSize;
7178
QVariantList m_things;
7279
QList<Barzle *> m_barzles;
7380
QList<Person *> m_cousins;
7481
QProperty<QByteArray> m_data;
82+
QRectF m_area;
7583
};
7684

7785
class BarzleListRegistration

0 commit comments

Comments
 (0)