diff options
author | Andrei Golubev <andrei.golubev@qt.io> | 2021-11-16 17:23:45 +0100 |
---|---|---|
committer | Andrei Golubev <andrei.golubev@qt.io> | 2021-11-23 18:01:05 +0100 |
commit | a12d59bfdfbd9e96849887a3a77ab195c6645d9a (patch) | |
tree | 12ca429535f7b758b5a210ed5efb1910aa97990e /src/qmlcompiler/qqmljsscope_p.h | |
parent | fc05eb9187e41521cf62b80e025f686b0864124d (diff) |
Improve QQmlJSMetaPropertyBinding usage
Rewrite the way we interact with this class:
* Add binding type, to allow switch-dispatch by this type.
Except for literal bindings, the type is set automatically
and then we can never reset it to something else
* Refactor methods to set all the relevant data at once (and
only once, due to the way binding type interaction works)
* Add Q_ASSERTs where relevant to check that our binding state
is valid
* Make QQmlJSScope::ownPropertyBinding() plural (because it is)
This allows us to have some built-in properties like binding
uniqueness and disallows us to do nasty things (like setting
incompatible data to the same binding)
Leave out the ability to only set a data type
(QWeakPointer<const QQmlJSScope>) since we don't use this in
practice. And due to QQmlJSScope not allowing us to refine bindings
after they have been added, we must not really add half-correct
bindings anyway
Document what various members of the binding do, because apparently
some pieces are reused across different kinds (e.g. m_value)
In the process of doing changes, try to leave the logic as is
(without too radical refactoring outside of the binding class)
Task-number: QTBUG-98407
Change-Id: I3a700cfab2353095b440ebb522cfb7d0655ce93e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljsscope_p.h')
-rw-r--r-- | src/qmlcompiler/qqmljsscope_p.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/qmlcompiler/qqmljsscope_p.h b/src/qmlcompiler/qqmljsscope_p.h index f9922a8f16..16e3f1722c 100644 --- a/src/qmlcompiler/qqmljsscope_p.h +++ b/src/qmlcompiler/qqmljsscope_p.h @@ -247,11 +247,13 @@ public: { return m_propertyBindings; } - QQmlJSMetaPropertyBinding ownPropertyBinding(const QString &name) const + QPair<QMultiHash<QString, QQmlJSMetaPropertyBinding>::const_iterator, + QMultiHash<QString, QQmlJSMetaPropertyBinding>::const_iterator> + ownPropertyBindings(const QString &name) const { - return m_propertyBindings.value(name); + return m_propertyBindings.equal_range(name); } - bool hasOwnPropertyBinding(const QString &name) const + bool hasOwnPropertyBindings(const QString &name) const { return m_propertyBindings.contains(name); } |