aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4compileddata.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2016-07-28 17:40:36 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2016-08-04 14:32:08 +0000
commitd77e544a568dbfff698c4d37c669bc991383fe9b (patch)
treefc48e7dae9ba9e53a6de1018ff3436182e7a8f58 /src/qml/compiler/qv4compileddata.cpp
parent1534dd6d97c49f5c7e0392df9c95198311b5b817 (diff)
Safeguard disk cache loading with checksum verification
When loading a QML component from the disk cache, compare the checksum of the dependent types against the checksum when the cache was created. Any change in the meta-object of a dependent type should trigger a re-creation discard of the cache and consequent re-creation (in the test-case). Unfortunately this also requires extending the existing hack in the unit test to deal with the low second precision on HFS+ in order to pass the tests. Change-Id: Ib8e899347680f7be676788388e9c23a09b0277e3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compileddata.cpp')
-rw-r--r--src/qml/compiler/qv4compileddata.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp
index 5948992f67..a4fffedbcd 100644
--- a/src/qml/compiler/qv4compileddata.cpp
+++ b/src/qml/compiler/qv4compileddata.cpp
@@ -301,6 +301,25 @@ void CompilationUnit::finalize(QQmlEnginePrivate *engine)
totalObjectCount = objectCount;
}
+bool CompilationUnit::verifyChecksum(QQmlEngine *engine,
+ const ResolvedTypeReferenceMap &dependentTypes) const
+{
+ if (dependentTypes.isEmpty()) {
+ for (size_t i = 0; i < sizeof(data->dependencyMD5Checksum); ++i) {
+ if (data->dependencyMD5Checksum[i] != 0)
+ return false;
+ }
+ return true;
+ }
+ QCryptographicHash hash(QCryptographicHash::Md5);
+ if (!dependentTypes.addToHash(&hash, engine))
+ return false;
+ QByteArray checksum = hash.result();
+ Q_ASSERT(checksum.size() == sizeof(data->dependencyMD5Checksum));
+ return memcmp(data->dependencyMD5Checksum, checksum.constData(),
+ sizeof(data->dependencyMD5Checksum)) == 0;
+}
+
bool CompilationUnit::saveToDisk(QString *errorString)
{
errorString->clear();