diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-02-05 15:45:01 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-02-07 17:49:52 +0000 |
commit | 1aae51242ed3902efac9524360f678113087f159 (patch) | |
tree | 07879896d7e8fc683c99b92e1e1acb50e610ae1c | |
parent | 8d0b649c6b6ebf64dd4f644a5a2b3b1fa34e57c9 (diff) | |
download | qtdeclarative-1aae51242ed3902efac9524360f678113087f159.tar.gz |
Add public methods to query and set allowed revisions of property caches
We should not poke around in the private objects for this.
Change-Id: If7089848d8310700a5a84efb0ff9b753a7de1f97
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r-- | src/qml/qml/qqmlmetatypedata.cpp | 7 | ||||
-rw-r--r-- | src/qml/qml/qqmlpropertycache_p.h | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/qml/qml/qqmlmetatypedata.cpp b/src/qml/qml/qqmlmetatypedata.cpp index c5b9ae1a15..989f1adf7c 100644 --- a/src/qml/qml/qqmlmetatypedata.cpp +++ b/src/qml/qml/qqmlmetatypedata.cpp @@ -129,12 +129,15 @@ QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QQmlType &type, int min int rev = currentType.metaObjectRevision(); int moIndex = types.count() - 1 - ii; - if (raw->allowedRevisionCache[moIndex] != rev) { + if (raw->allowedRevision(moIndex) != rev) { if (!hasCopied) { + // TODO: The copy should be mutable, and the original should be const + // Considering this, the setAllowedRevision() below does not violate + // the immutability of already published property caches. raw = raw->copy(); hasCopied = true; } - raw->allowedRevisionCache[moIndex] = rev; + raw->setAllowedRevision(moIndex, rev); } } diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h index 7369714f70..68f086e191 100644 --- a/src/qml/qml/qqmlpropertycache_p.h +++ b/src/qml/qml/qqmlpropertycache_p.h @@ -172,6 +172,10 @@ public: static bool addToHash(QCryptographicHash &hash, const QMetaObject &mo); QByteArray checksum(bool *ok); + + int allowedRevision(int index) const { return allowedRevisionCache[index]; } + void setAllowedRevision(int index, int allowed) { allowedRevisionCache[index] = allowed; } + private: friend class QQmlEnginePrivate; friend class QQmlCompiler; @@ -179,7 +183,6 @@ private: template <typename T> friend class QQmlPropertyCacheAliasCreator; friend class QQmlComponentAndAliasResolver; friend class QQmlMetaObject; - friend struct QQmlMetaTypeData; inline QQmlPropertyCache *copy(int reserve); |