diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2016-08-16 12:51:12 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-08-17 14:05:26 +0000 |
commit | a86e6e1821da51065b2fb3392c23da17e6e13f97 (patch) | |
tree | 68a6bdbf76d03e19bfb9e0730ccebd68eb05eb00 | |
parent | 39179d41f0b7278f869f3d746aa276940754875e (diff) |
Prospective fix for invalidating caches for qml files from resources
The Qt resource system does not store any time stamps, so to validation
purposes fall back to the time stamp of the application binary.
Change-Id: Ia1c4d06a634ffdb2d4d281aae55e5ed34f044a3c
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r-- | src/qml/compiler/qv4compilationunitmapper.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/qml/compiler/qv4compilationunitmapper.cpp b/src/qml/compiler/qv4compilationunitmapper.cpp index b53b7cf784..2e1213464c 100644 --- a/src/qml/compiler/qv4compilationunitmapper.cpp +++ b/src/qml/compiler/qv4compilationunitmapper.cpp @@ -42,6 +42,7 @@ #include "qv4compileddata_p.h" #include <QFileInfo> #include <QDateTime> +#include <QCoreApplication> QT_BEGIN_NAMESPACE @@ -77,7 +78,16 @@ bool CompilationUnitMapper::verifyHeader(const CompiledData::Unit *header, const { QFileInfo sourceCode(sourcePath); - if (sourceCode.exists() && sourceCode.lastModified().toMSecsSinceEpoch() != header->sourceTimeStamp) { + QDateTime sourceTimeStamp; + if (sourceCode.exists()) + sourceTimeStamp = sourceCode.lastModified(); + + // Files from the resource system do not have any time stamps, so fall back to the application + // executable. + if (!sourceTimeStamp.isValid()) + sourceTimeStamp = QFileInfo(QCoreApplication::applicationFilePath()).lastModified(); + + if (sourceTimeStamp.isValid() && sourceTimeStamp.toMSecsSinceEpoch() != header->sourceTimeStamp) { *errorString = QStringLiteral("QML source file has a different time stamp than cached file."); return false; } |