Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
5
#
include
"qv4resolvedtypereference_p.h"
6
7
#
include
<
QtQml
/
private
/
qqmlengine_p
.
h
>
8
#
include
<
QtQml
/
qqmlpropertymap
.
h
>
9
#
include
<
QtCore
/
qcryptographichash
.
h
>
10
11
QT_BEGIN_NAMESPACE
12
13
namespace
QV4
{
14
15
template
<
typename
T>
16
bool
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
25
void
ResolvedTypeReference
::
doDynamicTypeCheck
()
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
*/
40
QQmlPropertyCache
::
ConstPtr
ResolvedTypeReference
::
createPropertyCache
()
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
53
bool
ResolvedTypeReference
::
addToHash
(
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
77
QT_END_NAMESPACE
QV4::ResolvedTypeReference
Definition
qv4resolvedtypereference_p.h:33
QV4::ResolvedTypeReference::doDynamicTypeCheck
void doDynamicTypeCheck()
Definition
qv4resolvedtypereference.cpp:25
QV4::ResolvedTypeReference::addToHash
bool addToHash(QCryptographicHash *hash, QHash< quintptr, QByteArray > *checksums)
Definition
qv4resolvedtypereference.cpp:53
QV4::ResolvedTypeReference::createPropertyCache
QQmlPropertyCache::ConstPtr createPropertyCache()
Definition
qv4resolvedtypereference.cpp:40
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QV4
Definition
qjsvalue.h:24
QV4::qtTypeInherits
bool qtTypeInherits(const QMetaObject *mo)
Definition
qv4resolvedtypereference.cpp:16
qtdeclarative
src
qml
jsruntime
qv4resolvedtypereference.cpp
Generated on
for Qt by
1.18.0