From e0add0b655941dcec483674594b63ce9775598be Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 8 Mar 2017 17:09:55 +0100 Subject: Fix relocation related errors when loading AOT caches The original directory of the source file the cache was created from - when generating ahead of time - is unlikely going to be identical to the final location for example on a deployed device. Therefore when generating caches ahead of time, don't store the source path, don't attempt to verify it when loading and don't try to save the cache file at run-time again. We still need set the sourceFileIndex at load-time though, in order to make relative path url resolution work (for example source: "my.png" in an Image element). Change-Id: I3d6952f5d0a165cfa2cb400191a9f6ffe6be69f4 Reviewed-by: Lars Knoll --- src/qml/qml/qqmltypeloader.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/qml/qml/qqmltypeloader.cpp') diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index f4f04e12c0..68eb989c70 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -2407,6 +2407,7 @@ void QQmlTypeData::restoreIR(QQmlRefPointer m_document.reset(new QmlIR::Document(isDebugging())); QmlIR::IRLoader loader(unit->data, m_document.data()); loader.load(); + m_document->jsModule.setFileName(finalUrlString()); m_document->javaScriptCompilationUnit = unit; continueLoadFromIR(); } @@ -2507,6 +2508,8 @@ void QQmlTypeData::compile(const QQmlRefPointer &typeNameCach { Q_ASSERT(m_compiledData.isNull()); + const bool typeRecompilation = m_document && m_document->javaScriptCompilationUnit && m_document->javaScriptCompilationUnit->data->flags & QV4::CompiledData::Unit::PendingTypeCompilation; + QQmlEnginePrivate * const enginePrivate = QQmlEnginePrivate::get(typeLoader()->engine()); QQmlTypeCompiler compiler(enginePrivate, this, m_document.data(), typeNameCache, resolvedTypeCache); m_compiledData = compiler.compile(); @@ -2515,7 +2518,7 @@ void QQmlTypeData::compile(const QQmlRefPointer &typeNameCach return; } - const bool trySaveToDisk = (!disableDiskCache() || forceDiskCache()) && !m_document->jsModule.debugMode; + const bool trySaveToDisk = (!disableDiskCache() || forceDiskCache()) && !m_document->jsModule.debugMode && !typeRecompilation; if (trySaveToDisk) { QString errorString; if (m_compiledData->saveToDisk(url(), &errorString)) { -- cgit v1.2.3