diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2024-01-08 12:56:38 +0100 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2024-01-13 16:03:58 +0100 |
| commit | c225e23e00bc539daefa357f687fe4a1b51ade9f (patch) | |
| tree | 0cbb680ae5171ab0c84effd88af02d5b7bb3369a /src/qml/common/qv4compileddata.cpp | |
| parent | 21cf48781655e03c099e54f180f78e7435367386 (diff) | |
QtQml: Move ResolvedTypeReference into base CU
Change-Id: I25063457aad3a6d29a8c2a5b236f9a51b56a2f51
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/common/qv4compileddata.cpp')
| -rw-r--r-- | src/qml/common/qv4compileddata.cpp | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/src/qml/common/qv4compileddata.cpp b/src/qml/common/qv4compileddata.cpp index 14315084bd..16ef43f678 100644 --- a/src/qml/common/qv4compileddata.cpp +++ b/src/qml/common/qv4compileddata.cpp @@ -3,9 +3,10 @@ #include "qv4compileddata_p.h" +#include <private/qv4resolvedtypereference_p.h> + #include <QtQml/qqmlfile.h> -#include <QtCore/qcryptographichash.h> #include <QtCore/qdir.h> #include <QtCore/qscopeguard.h> #include <QtCore/qstandardpaths.h> @@ -15,6 +16,48 @@ QT_BEGIN_NAMESPACE namespace QV4 { namespace CompiledData { +/*! + \internal + This function creates a temporary key vector and sorts it to guarantuee a stable + hash. This is used to calculate a check-sum on dependent meta-objects. + */ +bool ResolvedTypeReferenceMap::addToHash( + QCryptographicHash *hash, QHash<quintptr, QByteArray> *checksums) const +{ + std::vector<int> keys (size()); + int i = 0; + for (auto it = constBegin(), end = constEnd(); it != end; ++it) { + keys[i] = it.key(); + ++i; + } + std::sort(keys.begin(), keys.end()); + for (int key: keys) { + if (!this->operator[](key)->addToHash(hash, checksums)) + return false; + } + + return true; +} + +CompilationUnit::~CompilationUnit() +{ + qDeleteAll(resolvedTypes); + + if (data) { + if (data->qmlUnit() != qmlData) + free(const_cast<QmlUnit *>(qmlData)); + qmlData = nullptr; + + if (!(data->flags & QV4::CompiledData::Unit::StaticData)) + free(const_cast<Unit *>(data)); + } + data = nullptr; +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + delete [] constants; + constants = nullptr; +#endif +} + QString CompilationUnit::localCacheFilePath(const QUrl &url) { static const QByteArray envCachePath = qgetenv("QML_DISK_CACHE_PATH"); @@ -117,6 +160,16 @@ QStringList CompilationUnit::moduleRequests() const return requests; } +ResolvedTypeReference *CompilationUnit::resolvedType(QMetaType type) const +{ + for (ResolvedTypeReference *ref : std::as_const(resolvedTypes)) { + if (ref->type().typeId() == type) + return ref; + } + return nullptr; + +} + } // namespace CompiledData } // namespace QV4 |
