From 47ddbb72e052989622f5fa23e032c787bed5f2e5 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 22 Dec 2023 14:06:34 +0100 Subject: QtQml: Get rid of the module mutex It only exists so that the type loader can query pre-compiled and native modules from the loader thread. However, the type loader already has a mutex of its own. We can use that to inject a "native" blob into its script cache for the same effect. We need to get rid of the mutex so that we can use the module map for other compilation units, too. Change-Id: I5a9c266ea36b50f5ea69214110def644f7501674 Reviewed-by: Fabian Kosmale --- src/qml/common/qv4compileddata.cpp | 9 +++++++++ src/qml/common/qv4compileddata_p.h | 39 ++++++++++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 4 deletions(-) (limited to 'src/qml/common') diff --git a/src/qml/common/qv4compileddata.cpp b/src/qml/common/qv4compileddata.cpp index 4ed53e6907..14315084bd 100644 --- a/src/qml/common/qv4compileddata.cpp +++ b/src/qml/common/qv4compileddata.cpp @@ -108,6 +108,15 @@ bool CompilationUnit::saveToDisk(const QUrl &unitUrl, QString *errorString) }); } +QStringList CompilationUnit::moduleRequests() const +{ + QStringList requests; + requests.reserve(data->moduleRequestTableSize); + for (uint i = 0; i < data->moduleRequestTableSize; ++i) + requests << stringAt(data->moduleRequestTable()[i]); + return requests; +} + } // namespace CompiledData } // namespace QV4 diff --git a/src/qml/common/qv4compileddata_p.h b/src/qml/common/qv4compileddata_p.h index f7654661e2..0c7b07936c 100644 --- a/src/qml/common/qv4compileddata_p.h +++ b/src/qml/common/qv4compileddata_p.h @@ -16,14 +16,15 @@ #include +#include #include -#include +#include #include -#include +#include #include -#include +#include +#include #include -#include #if QT_CONFIG(temporaryfile) #include @@ -33,6 +34,7 @@ #include #include #include +#include #include #include @@ -1558,9 +1560,38 @@ public: const QUrl &url, const QDateTime &sourceTimeStamp, QString *errorString); Q_QML_EXPORT bool saveToDisk(const QUrl &unitUrl, QString *errorString); + int importCount() const { return qmlData->nImports; } + const CompiledData::Import *importAt(int index) const { return qmlData->importAt(index); } + + Q_QML_EXPORT QStringList moduleRequests() const; + + // url() and fileName() shall be used to load the actual QML/JS code or to show errors or + // warnings about that code. They include any potential URL interceptions and thus represent the + // "physical" location of the code. + // + // finalUrl() and finalUrlString() shall be used to resolve further URLs referred to in the code + // They are _not_ intercepted and thus represent the "logical" name for the code. + + QUrl url() const + { + if (!m_url.isValid()) + m_url = QUrl(fileName()); + return m_url; + } + + QUrl finalUrl() const + { + if (!m_finalUrl.isValid()) + m_finalUrl = QUrl(finalUrlString()); + return m_finalUrl; + } + private: QString m_fileName; // initialized from data->sourceFileIndex QString m_finalUrlString; // initialized from data->finalUrlIndex + + mutable QQmlNullableValue m_url; + mutable QQmlNullableValue m_finalUrl; }; class SaveableUnitPointer -- cgit v1.2.3