diff options
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 |
