From aff417321d0aad5da462a63b103b82bc19809841 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 7 Sep 2017 13:02:57 +0200 Subject: Fix crashes in QML apps when upgrading Qt snapshots When upgrading from one Qt snapshot to another, we may not end up bumping the Qt version. However we do need to re-generate QML cache files. Therefore let's encode the commit hash of declarative in the checksums. Task-number: QTBUG-62302 Change-Id: Ia597fcbe05ea2d32664da2572a1b35c624490095 Reviewed-by: Joerg Bornemann --- src/qml/compiler/qv4compileddata.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/qml/compiler/qv4compileddata.cpp') diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index 32e8ee4da2..6702966d11 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -731,8 +731,6 @@ void ResolvedTypeReference::doDynamicTypeCheck() isFullyDynamicType = qtTypeInherits(mo); } -#if defined(QT_BUILD_INTERNAL) - static QByteArray ownLibraryChecksum() { static QByteArray libraryChecksum; @@ -740,7 +738,10 @@ static QByteArray ownLibraryChecksum() if (checksumInitialized) return libraryChecksum; checksumInitialized = true; -#if !defined(QT_NO_DYNAMIC_CAST) && QT_CONFIG(dlopen) +#if defined(QT_BUILD_INTERNAL) && !defined(QT_NO_DYNAMIC_CAST) && QT_CONFIG(dlopen) + // This is a bit of a hack to make development easier. When hacking on the code generator + // the cache files may end up being re-used. To avoid that we also add the checksum of + // the QtQml library. Dl_info libInfo; if (dladdr(reinterpret_cast(&ownLibraryChecksum), &libInfo) != 0) { QFile library(QFile::decodeName(libInfo.dli_fname)); @@ -750,14 +751,14 @@ static QByteArray ownLibraryChecksum() libraryChecksum = hash.result(); } } +#elif defined(QML_COMPILE_HASH) + libraryChecksum = QByteArray(QT_STRINGIFY(QML_COMPILE_HASH)); #else // Not implemented. #endif return libraryChecksum; } -#endif - bool ResolvedTypeReferenceMap::addToHash(QCryptographicHash *hash, QQmlEngine *engine) const { for (auto it = constBegin(), end = constEnd(); it != end; ++it) { @@ -765,12 +766,7 @@ bool ResolvedTypeReferenceMap::addToHash(QCryptographicHash *hash, QQmlEngine *e return false; } - // This is a bit of a hack to make development easier. When hacking on the code generator - // the cache files may end up being re-used. To avoid that we also add the checksum of - // the QtQml library. -#if defined(QT_BUILD_INTERNAL) hash->addData(ownLibraryChecksum()); -#endif return true; } -- cgit v1.2.3