diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/plugins/qmltooling/qmldbg_preview/qqmlpreviewhandler.cpp | 3 | ||||
| -rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 34 | ||||
| -rw-r--r-- | src/qml/qml/qqmlscriptblob.cpp | 5 | ||||
| -rw-r--r-- | src/qml/qml/qqmltypedata.cpp | 15 |
4 files changed, 11 insertions, 46 deletions
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewhandler.cpp b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewhandler.cpp index ae5808e2be..b311e397f2 100644 --- a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewhandler.cpp +++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewhandler.cpp @@ -152,7 +152,8 @@ void QQmlPreviewHandler::loadUrl(const QUrl &url) void QQmlPreviewHandler::dropCU(const QUrl &url) { // Drop any existing compilation units for this URL from the type registry. - if (const auto cu = QQmlMetaType::obtainCompilationUnit(url)) + // There can be multiple, one for each engine. + while (const auto cu = QQmlMetaType::obtainCompilationUnit(url)) QQmlMetaType::unregisterInternalCompositeType(cu); } diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 59d2d6c7fa..5df48560e3 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -14,6 +14,7 @@ #include <private/qqmljsdiagnosticmessage_p.h> #include <private/qqmllist_p.h> #include <private/qqmllistwrapper_p.h> +#include <private/qqmlscriptblob_p.h> #include <private/qqmlscriptdata_p.h> #include <private/qqmltypeloader_p.h> #include <private/qqmltypewrapper_p.h> @@ -2165,37 +2166,8 @@ ExecutionEngine::Module ExecutionEngine::moduleForUrl( return *existingModule; } - // Compilation Unit present in QQmlMetaTypeData - if (auto cu = QQmlMetaType::obtainCompilationUnit(resolved)) - return executableCompilationUnit(std::move(cu)); - - // Compilation Unit readily loadable from .qmlc file or binary - QQmlMetaType::CachedUnitLookupError cacheError = QQmlMetaType::CachedUnitLookupError::NoError; - const DiskCacheOptions options = diskCacheOptions(); - if (const QQmlPrivate::CachedQmlUnit *cachedUnit = (options & DiskCache::Aot) - ? QQmlMetaType::findCachedCompilationUnit( - resolved, - (options & DiskCache::AotByteCode) - ? QQmlMetaType::AcceptUntyped - : QQmlMetaType::RequireFullyTyped, - &cacheError) - : nullptr) { - const auto cu = executableCompilationUnit( - QQml::makeRefPointer<QV4::CompiledData::CompilationUnit>( - cachedUnit->qmlData, cachedUnit->aotCompiledFunctions, - resolved.fileName(), resolved.toString())); - const auto data = cu->unitData(); - for (uint i = 0, end = data->moduleRequestTableSize; i < end; ++i) { - const auto dependency = moduleForUrl(cu->urlAt(data->moduleRequestTable()[i]), cu.data()); - QQmlRefPointer<QQmlScriptData> scriptData( - new QQmlScriptData, QQmlRefPointer<QQmlScriptData>::Adopt); - scriptData->url = dependency->finalUrl(); - scriptData->urlString = dependency->finalUrlString(); - scriptData->m_precompiledScript = dependency->baseCompilationUnit(); - cu->baseCompilationUnit()->dependentScripts.append(std::move(scriptData)); - } - return cu; - } + if (const auto blob = m_typeLoader->getScript(resolved, QQmlTypeLoader::Synchronous)) + return executableCompilationUnit(blob->scriptData()->compilationUnit()); // Unavailable return Module(); diff --git a/src/qml/qml/qqmlscriptblob.cpp b/src/qml/qml/qqmlscriptblob.cpp index c08bcb62e0..a34d7acc2b 100644 --- a/src/qml/qml/qqmlscriptblob.cpp +++ b/src/qml/qml/qqmlscriptblob.cpp @@ -30,11 +30,6 @@ void QQmlScriptBlob::dataReceived(const SourceCodeData &data) assertTypeLoaderThread(); if (data.isCacheable()) { - if (auto unit = QQmlMetaType::obtainCompilationUnit(url())) { - initializeFromCompilationUnit(std::move(unit)); - return; - } - if (m_typeLoader->readCacheFile()) { auto unit = QQml::makeRefPointer<QV4::CompiledData::CompilationUnit>(); QString error; diff --git a/src/qml/qml/qqmltypedata.cpp b/src/qml/qml/qqmltypedata.cpp index 0faed498fe..b60adb2bfe 100644 --- a/src/qml/qml/qqmltypedata.cpp +++ b/src/qml/qml/qqmltypedata.cpp @@ -65,9 +65,6 @@ bool QQmlTypeData::tryLoadFromDiskCache() if (!m_backupSourceCode.isCacheable()) return false; - if (auto unit = QQmlMetaType::obtainCompilationUnit(url())) - return loadFromDiskCache(unit); - if (!m_typeLoader->readCacheFile()) return false; @@ -746,11 +743,6 @@ void QQmlTypeData::initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *un { assertTypeLoaderThread(); - if (auto cu = QQmlMetaType::obtainCompilationUnit(finalUrl())) { - if (loadFromDiskCache(cu)) - return; - } - if (unit->qmlData->qmlUnit()->nObjects == 0) { setError(QQmlTypeLoader::tr("Cached QML Unit has no objects")); return; @@ -1119,8 +1111,13 @@ QQmlError QQmlTypeData::buildTypeResolutionCaches( // this is required for inline components in singletons const QMetaType type = qmlType.typeId(); ref->setTypePropertyCache(QQmlMetaType::propertyCacheForType(type)); - if (resolvedType->needsCreation) + if (resolvedType->needsCreation) { + // TODO: Obtaining a compilation unit from the type registry is OK-ish + // here because the type is unique to the engine. What we actually + // want is to have a nullptr CU if the respective inline component + // doesn't exist. There should be a simpler way to do this. ref->setCompilationUnit(QQmlMetaType::obtainCompilationUnit(type)); + } } } else if (qmlType.isValid() && !resolvedType->selfReference) { Q_ASSERT(ref->type().isValid()); |
