aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4resolvedtypereference.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/jsruntime/qv4resolvedtypereference.cpp')
-rw-r--r--src/qml/jsruntime/qv4resolvedtypereference.cpp75
1 files changed, 29 insertions, 46 deletions
diff --git a/src/qml/jsruntime/qv4resolvedtypereference.cpp b/src/qml/jsruntime/qv4resolvedtypereference.cpp
index d81f512391..7dcf2cd0b8 100644
--- a/src/qml/jsruntime/qv4resolvedtypereference.cpp
+++ b/src/qml/jsruntime/qv4resolvedtypereference.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qv4resolvedtypereference_p.h"
@@ -72,7 +36,7 @@ void ResolvedTypeReference::doDynamicTypeCheck()
/*!
Returns the property cache, if one alread exists. The cache is not referenced.
*/
-QQmlRefPointer<QQmlPropertyCache> ResolvedTypeReference::propertyCache() const
+QQmlPropertyCache::ConstPtr ResolvedTypeReference::propertyCache() const
{
if (m_type.isValid())
return m_typePropertyCache;
@@ -83,12 +47,16 @@ QQmlRefPointer<QQmlPropertyCache> ResolvedTypeReference::propertyCache() const
/*!
Returns the property cache, creating one if it doesn't already exist. The cache is not referenced.
*/
-QQmlRefPointer<QQmlPropertyCache> ResolvedTypeReference::createPropertyCache(QQmlEngine *engine)
+QQmlPropertyCache::ConstPtr ResolvedTypeReference::createPropertyCache()
{
if (m_typePropertyCache) {
return m_typePropertyCache;
} else if (m_type.isValid()) {
- m_typePropertyCache = QQmlEnginePrivate::get(engine)->cache(m_type.metaObject(), m_version);
+ const QMetaObject *metaObject = m_type.metaObject();
+ if (!metaObject) // value type of non-Q_GADGET base with extension
+ metaObject = m_type.extensionMetaObject();
+ if (metaObject)
+ m_typePropertyCache = QQmlMetaType::propertyCache(metaObject, m_version);
return m_typePropertyCache;
} else {
Q_ASSERT(m_compilationUnit);
@@ -96,17 +64,32 @@ QQmlRefPointer<QQmlPropertyCache> ResolvedTypeReference::createPropertyCache(QQm
}
}
-bool ResolvedTypeReference::addToHash(QCryptographicHash *hash, QQmlEngine *engine)
+bool ResolvedTypeReference::addToHash(
+ QCryptographicHash *hash, QHash<quintptr, QByteArray> *checksums)
{
- if (m_type.isValid() && !m_type.isInlineComponentType()) {
+ if (m_type.isInlineComponentType()) {
+
+ // A reference to an inline component in the same file will have
+ // - no compilation unit since we cannot resolve the compilation unit before it's built.
+ // - a property cache since we've assigned one in buildMetaObjectsIncrementally().
+ // - a QQmlType that says it's an inline component.
+ // We don't have to add such a thing to the hash since if it changes, the QML document
+ // itself changes, leading to a new timestamp, which is checked before the checksum.
+ if (!m_compilationUnit)
+ return !m_typePropertyCache.isNull();
+
+ } else if (m_type.isValid()) {
bool ok = false;
- hash->addData(createPropertyCache(engine)->checksum(&ok));
+ if (QQmlPropertyCache::ConstPtr propertyCache = createPropertyCache())
+ hash->addData(propertyCache->checksum(checksums, &ok));
+ else
+ Q_ASSERT(m_type.module() == QLatin1String("QML")); // a builtin without metaobject
return ok;
}
if (!m_compilationUnit)
return false;
- hash->addData(m_compilationUnit->data->md5Checksum,
- sizeof(m_compilationUnit->data->md5Checksum));
+ hash->addData({m_compilationUnit->unitData()->md5Checksum,
+ sizeof(m_compilationUnit->unitData()->md5Checksum)});
return true;
}