diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2025-10-06 10:09:01 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2025-10-07 07:41:21 +0200 |
| commit | f5e34266ea15c6e44e9816f01f4e627d5f038f0c (patch) | |
| tree | 4e898b2d1f37f8c19602ed6e4381bb6b30989121 /tests/auto/qml/qmlcppcodegen/data/variantMapLookup.h | |
| parent | ba56f1e4638f9752903d587129b0474e845ce416 (diff) | |
QmlCompiler: Fix write access to QVariantMap
Without this, it tries to resolve the metaObject of QVariantMap, which
crashes.
Amends commit cca07aa78841f2d743f0b4d933abb0dd66f0b948.
Fixes: QTBUG-139626
Pick-to: 6.10 6.8
Change-Id: Id747429ed0d558932b9a6cb8f59e3740982efb56
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/data/variantMapLookup.h')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/variantMapLookup.h | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/variantMapLookup.h b/tests/auto/qml/qmlcppcodegen/data/variantMapLookup.h index de7ac4f739..c1e52062b5 100644 --- a/tests/auto/qml/qmlcppcodegen/data/variantMapLookup.h +++ b/tests/auto/qml/qmlcppcodegen/data/variantMapLookup.h @@ -7,19 +7,32 @@ class VariantMapLookupFoo : public QObject { Q_OBJECT QML_ELEMENT - Q_PROPERTY(QVariantMap data READ data CONSTANT) - Q_PROPERTY(QList<QVariantMap> many READ many CONSTANT) + Q_PROPERTY(QVariantMap data READ data WRITE setData NOTIFY dataChanged) + Q_PROPERTY(QList<QVariantMap> many READ many NOTIFY dataChanged) public: VariantMapLookupFoo(QObject *parent = nullptr) : QObject(parent) { } -private: - QVariantMap data() const { return { { QStringLiteral("value"), 42 } }; } + QVariantMap data() const { return m_data; } + void setData(const QVariantMap &data) + { + if (data == m_data) + return; + m_data = data; + emit dataChanged(); + } + QList<QVariantMap> many() const { const QVariantMap one = data(); return QList<QVariantMap>({one, one, one}); } + +signals: + void dataChanged(); + +private: + QVariantMap m_data; }; |
