diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2016-09-10 13:00:48 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2016-09-12 21:37:29 +0000 |
commit | 777109347c837b07b4463d68257cda65ed7f3bac (patch) | |
tree | 144d499a41901be9f4563a9000b07213c79e10d4 /src/qml/qml/qqmlpropertycache.cpp | |
parent | a014c9acf50844bb4833bac078a9c85feda43522 (diff) |
Use the stringData() function from qmetaobject.cpp
It does some extra checking. This adds a comment so that we won't forget
to update it if the source changes too.
Change-Id: I9093948278414644a416fffd14730eb6b8dfe585
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlpropertycache.cpp')
-rw-r--r-- | src/qml/qml/qqmlpropertycache.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp index b9e2213035..337c37b5be 100644 --- a/src/qml/qml/qqmlpropertycache.cpp +++ b/src/qml/qml/qqmlpropertycache.cpp @@ -1091,9 +1091,21 @@ QQmlPropertyCache::property(QJSEngine *engine, QObject *obj, return qQmlPropertyCacheProperty<const QString &>(engine, obj, name, context, local); } +// these two functions are copied from qmetaobject.cpp static inline const QMetaObjectPrivate *priv(const uint* data) { return reinterpret_cast<const QMetaObjectPrivate*>(data); } +static inline const QByteArray stringData(const QMetaObject *mo, int index) +{ + Q_ASSERT(priv(mo->d.data)->revision >= 7); + const QByteArrayDataPtr data = { const_cast<QByteArrayData*>(&mo->d.stringdata[index]) }; + Q_ASSERT(data.ptr->ref.isStatic()); + Q_ASSERT(data.ptr->alloc == 0); + Q_ASSERT(data.ptr->capacityReserved == 0); + Q_ASSERT(data.ptr->size >= 0); + return data; +} + bool QQmlPropertyCache::isDynamicMetaObject(const QMetaObject *mo) { return priv(mo->d.data)->revision >= 3 && priv(mo->d.data)->flags & DynamicMetaObject; @@ -1399,8 +1411,7 @@ bool QQmlPropertyCache::addToHash(QCryptographicHash &hash, const QMetaObject &m hash.addData(reinterpret_cast<const char *>(mo.d.data), fieldCount * sizeof(uint)); for (int i = 0; i < stringCount; ++i) { - const QByteArrayDataPtr data = { const_cast<QByteArrayData*>(&mo.d.stringdata[i]) }; - hash.addData(QByteArray(data)); + hash.addData(stringData(&mo, i)); } return true; |