diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2025-03-28 09:20:09 +0100 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2025-03-31 08:29:52 +0000 |
| commit | c36416c9713f9ac98529affadf07b05d8b6ae95e (patch) | |
| tree | 188f9b8dba853598c8ac77421a0f4b54998ad3bf /tests/auto/qml/qmlcppcodegen/data | |
| parent | d9145dd37e57aad18d99fae1d20c571c1ead30e6 (diff) | |
QmlCompiler: Do not re-resolve iterator value types
We've resolved the value type in the type propagator. Trying to do it
again in the code generator, after the iterator may have been adjusted,
is quite wrong. If we resolve the list value type on a type that's not
a list (anymore), then we get an invalid type, which subsequently
crashes.
Amends commit a173d50a9e54d2a21a5207f6c66bb54bb8f3a612.
Pick-to: 6.9 6.8
Fixes: QTBUG-135288
Change-Id: I1227803ed100c83f8fc11898be0a4d0199d639dd
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/data')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/iterateUnknownValue.qml | 13 | ||||
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/listsingleton.h | 22 |
3 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt index 72f18810a7..53435306fa 100644 --- a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt +++ b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt @@ -19,6 +19,7 @@ set(cpp_sources invisible.h largeValueType.h listprovider.h + listsingleton.h multiforeign.h objectwithmethod.h person.cpp person.h @@ -193,6 +194,7 @@ set(qml_files invisibleListElementType.qml invisibleTypes.qml isnan.qml + iterateUnknownValue.qml iteration.qml javaScriptArgument.qml jsArrayMethods.qml diff --git a/tests/auto/qml/qmlcppcodegen/data/iterateUnknownValue.qml b/tests/auto/qml/qmlcppcodegen/data/iterateUnknownValue.qml new file mode 100644 index 0000000000..d9164f7215 --- /dev/null +++ b/tests/auto/qml/qmlcppcodegen/data/iterateUnknownValue.qml @@ -0,0 +1,13 @@ +import QtQml +import TestTypes as PC + +QtObject { + Component.onCompleted: { + const theList = PC.ListSingleton.get() + if (theList) { + for (let entry of theList) { + console.log(entry) + } + } + } +} diff --git a/tests/auto/qml/qmlcppcodegen/data/listsingleton.h b/tests/auto/qml/qmlcppcodegen/data/listsingleton.h new file mode 100644 index 0000000000..06fe993584 --- /dev/null +++ b/tests/auto/qml/qmlcppcodegen/data/listsingleton.h @@ -0,0 +1,22 @@ +#ifndef LISTSINGLETON_H +#define LISTSINGLETON_H + +#include <QObject> +#include <QtQml/qqml.h> +#include <QtQml/qqmlregistration.h> + +class ListSingleton : public QObject { + Q_OBJECT + QML_ELEMENT + QML_SINGLETON + +public: + ListSingleton(QObject *parent = nullptr) : QObject(parent) {} + + Q_INVOKABLE QStringList get() const + { + return { QStringLiteral("one"), QStringLiteral("two"), QStringLiteral("three") }; + } +}; + +#endif // LISTSINGLETON_H |
