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 /src/qml/qml/qqmlpropertydata_p.h | |
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 'src/qml/qml/qqmlpropertydata_p.h')
-rw-r--r-- | src/qml/qml/qqmlpropertydata_p.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/qml/qml/qqmlpropertydata_p.h b/src/qml/qml/qqmlpropertydata_p.h index eda2402ada..edf777ff18 100644 --- a/src/qml/qml/qqmlpropertydata_p.h +++ b/src/qml/qml/qqmlpropertydata_p.h @@ -281,6 +281,7 @@ public: { Q_ASSERT(idx >= std::numeric_limits<qint16>::min()); Q_ASSERT(idx <= std::numeric_limits<qint16>::max()); + Q_ASSERT(idx != m_coreIndex); m_overrideIndex = qint16(idx); } @@ -344,7 +345,7 @@ public: QString name(QObject *) const; QString name(const QMetaObject *) const; - void markAsOverrideOf(QQmlPropertyData *predecessor); + bool markAsOverrideOf(QQmlPropertyData *predecessor); inline void readProperty(QObject *target, void *property) const { |