diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-05-14 10:36:48 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-06-02 21:04:35 +0200 |
commit | ba2928c787cf0988a7f6a7d424faea96ff707846 (patch) | |
tree | 01788110ab68d2b9a1e8fa504bca2ee519fb5c24 /tests/auto/qml/qqmlpropertycache/data | |
parent | 278e8df17b073f96d8ff89d7a470fe63802ed15e (diff) |
Reject overrides of final properties (and potentially methods)
If you specify FINAL in Q_PROPERTY you explicitly don't want it to be
overridden. Before, we would still accept overrides of such properties.
Issue a warning and decline overriding them.
For consistency, treat methods the same, even though we cannot declare
them final yet.
[ChangeLog][QtQml][Important Behavior Changes] C++ properties declared
FINAL now refuse to be overridden by other C++ properties. This mirrors
the treatment of QML properties trying to override FINAL properties. As
we cannot reject the C++ types the way we can reject QML types, the
overrides are ignored and a warning is issued. It is also impossible to
override final properties with functions now. This used to be possible
in the past.
Task-number: QTBUG-93662
Change-Id: I244c3e83a33875472bc5bf6786a1e949fe981995
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlpropertycache/data')
-rw-r--r-- | tests/auto/qml/qqmlpropertycache/data/finalProp.qml | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlpropertycache/data/finalProp.qml b/tests/auto/qml/qqmlpropertycache/data/finalProp.qml new file mode 100644 index 0000000000..1133ddc292 --- /dev/null +++ b/tests/auto/qml/qqmlpropertycache/data/finalProp.qml @@ -0,0 +1,18 @@ +import QtQml +import Test.PropertyCache + +QtObject { + property BaseObject obj: BaseObject {} + property int a: obj.finalProp + + property BaseObject obj2: BaseObject { + property int callCount: 0 + function finalProp() { ++callCount } + Component.onCompleted: finalProp() + } + + property var b: obj2.finalProp + Component.onCompleted: obj2.finalProp() + + property int c: obj2.callCount +} |