Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qv4resolvedtypereference.cpp
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant
4
6
7#include <QtQml/private/qqmlengine_p.h>
8#include <QtQml/qqmlpropertymap.h>
9#include <QtCore/qcryptographichash.h>
10
12
13namespace QV4 {
14
15template <typename T>
16bool qtTypeInherits(const QMetaObject *mo) {
17 while (mo) {
18 if (mo == &T::staticMetaObject)
19 return true;
20 mo = mo->superClass();
21 }
22 return false;
23}
24
26{
27 const QMetaObject *mo = nullptr;
28 if (m_typePropertyCache)
29 mo = m_typePropertyCache->firstCppMetaObject();
30 else if (m_type.isValid())
31 mo = m_type.metaObject();
32 m_isFullyDynamicType = qtTypeInherits<QQmlPropertyMap>(mo);
33}
34
35/*!
36 \internal
37 Returns the property cache, creating one if it doesn't already exist. The
38 cache is not referenced.
39*/
41{
42 if (!m_typePropertyCache && m_type.isValid()) {
43 const QMetaObject *metaObject = m_type.metaObject();
44 if (!metaObject) // value type of non-Q_GADGET base with extension
45 metaObject = m_type.extensionMetaObject();
46 if (metaObject)
47 m_typePropertyCache = QQmlMetaType::propertyCache(metaObject, m_version);
48 }
49
50 return m_typePropertyCache;
51}
52
54 QCryptographicHash *hash, QHash<quintptr, QByteArray> *checksums)
55{
56 // No need to add types from the same document to the hash.
57 if (m_isSelfReference)
58 return true;
59
60 if (m_compilationUnit) {
61 hash->addData({m_compilationUnit->unitData()->md5Checksum,
62 sizeof(m_compilationUnit->unitData()->md5Checksum)});
63 return true;
64 }
65
66 if (QQmlPropertyCache::ConstPtr propertyCache = createPropertyCache()) {
67 bool ok = false;
68 hash->addData(propertyCache->checksum(checksums, &ok));
69 return ok;
70 }
71
72 return false;
73}
74
75} // namespace QV4
76
77QT_END_NAMESPACE
bool addToHash(QCryptographicHash *hash, QHash< quintptr, QByteArray > *checksums)
QQmlPropertyCache::ConstPtr createPropertyCache()
Combined button and popup list for selecting options.
Definition qjsvalue.h:23
bool qtTypeInherits(const QMetaObject *mo)