diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2023-02-10 09:07:38 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-02-11 05:18:17 +0000 |
commit | 9f10edb60a2834baed0a8c1c02a2262c498703ef (patch) | |
tree | caa34881233f2480f0ab286ceabc24581526498c /src | |
parent | 176e6eb8357535d19d3ca079c71b96915c1bef9c (diff) |
QML: Invalidate any existing cache files when saving a CU to disk
Otherwise we just re-load the old cache file next time. That's clearly
not intended.
Fixes: QTBUG-111078
Change-Id: Ia65b46880eca2b6e8c4792a09f20716125beada3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 0a5eff09203ebb2547431de689d9c07e6c97f636)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/jsruntime/qv4compilationunitmapper.cpp | 11 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4compilationunitmapper_p.h | 1 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4executablecompilationunit.cpp | 10 |
3 files changed, 20 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4compilationunitmapper.cpp b/src/qml/jsruntime/qv4compilationunitmapper.cpp index da11c29caf..1b96300cdf 100644 --- a/src/qml/jsruntime/qv4compilationunitmapper.cpp +++ b/src/qml/jsruntime/qv4compilationunitmapper.cpp @@ -65,6 +65,11 @@ public: s_staticUnits.insert(file, staticUnit); } + void remove(const QString &file) + { + s_staticUnits.remove(file); + } + private: QMutexLocker<QMutex> m_lock; @@ -105,4 +110,10 @@ CompiledData::Unit *CompilationUnitMapper::get( return data; } +void CompilationUnitMapper::invalidate(const QString &cacheFilePath) +{ + StaticUnitCache cache; + cache.remove(cacheFilePath); +} + QT_END_NAMESPACE diff --git a/src/qml/jsruntime/qv4compilationunitmapper_p.h b/src/qml/jsruntime/qv4compilationunitmapper_p.h index 353237ce35..1def1ed468 100644 --- a/src/qml/jsruntime/qv4compilationunitmapper_p.h +++ b/src/qml/jsruntime/qv4compilationunitmapper_p.h @@ -69,6 +69,7 @@ public: CompiledData::Unit *get( const QString &cacheFilePath, const QDateTime &sourceTimeStamp, QString *errorString); + static void invalidate(const QString &cacheFilePath); private: CompiledData::Unit *open( diff --git a/src/qml/jsruntime/qv4executablecompilationunit.cpp b/src/qml/jsruntime/qv4executablecompilationunit.cpp index 4de044377b..f48e2dda96 100644 --- a/src/qml/jsruntime/qv4executablecompilationunit.cpp +++ b/src/qml/jsruntime/qv4executablecompilationunit.cpp @@ -857,8 +857,14 @@ bool ExecutableCompilationUnit::saveToDisk(const QUrl &unitUrl, QString *errorSt return CompiledData::SaveableUnitPointer(unitData()).saveToDisk<char>( [&unitUrl, errorString](const char *data, quint32 size) { - return CompiledData::SaveableUnitPointer::writeDataToFile(localCacheFilePath(unitUrl), data, - size, errorString); + const QString cachePath = localCacheFilePath(unitUrl); + if (CompiledData::SaveableUnitPointer::writeDataToFile( + cachePath, data, size, errorString)) { + CompilationUnitMapper::invalidate(cachePath); + return true; + } + + return false; }); } |