diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2025-09-11 09:17:18 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2025-09-15 14:55:42 +0200 |
| commit | 7105eb6d0d46949e235d213cfe77dda95f16c6c5 (patch) | |
| tree | 78ae959547ca9842c4e600dc1c7dd56af309fbba /tests/auto/qml/qmlcppcodegen/data | |
| parent | de368f8f4decdab3a9f0718ad9bcb86934f17c47 (diff) | |
QmlCompiler: Guard against disappearing arrow functions
You can override a QObject method with a JavaScript function and take
away the JavaScript function later by swapping out objects. This should
not crash.
Pick-to: 6.10 6.9
Fixes: QTBUG-140074
Change-Id: I85b17f4f619235024d0f1a27b4ff4128c7a57083
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/data')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/disappearingArrowFunction.qml | 28 |
2 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt index efd95ce64f..29b272c440 100644 --- a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt +++ b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt @@ -151,6 +151,7 @@ set(qml_files detachedreferences.qml dialog.qml dialogButtonBox.qml + disappearingArrowFunction.qml dynamicscene.qml enforceSignature.qml enumConversion.qml diff --git a/tests/auto/qml/qmlcppcodegen/data/disappearingArrowFunction.qml b/tests/auto/qml/qmlcppcodegen/data/disappearingArrowFunction.qml new file mode 100644 index 0000000000..cb97ab5c02 --- /dev/null +++ b/tests/auto/qml/qmlcppcodegen/data/disappearingArrowFunction.qml @@ -0,0 +1,28 @@ +pragma Strict +import QtQml + +QtObject { + property Person inner: Person { + function getName() : int { return 5 } + } + + property Person none: Person {} + + property Person evil: Person { + property string getName: "not a function" + } + + onObjectNameChanged: console.log(inner.getName()) + + function swapNone() { + let t = inner; + inner = none; + none = t; + } + + function swapEvil() { + let t = inner; + inner = evil; + evil = t; + } +} |
