From 5d8f6beb4640d64a262fa918b47e0073ea39fbda Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 16 Sep 2020 08:56:13 +0200 Subject: rcc: Make output deterministic for directories QDirIterator is documented to be non-deterministic. Fixes: QTBUG-86675 Pick-to: 5.15 Change-Id: I4161871a409bbaf85347ee6a60ef1189f56a1b22 Reviewed-by: hjk --- src/tools/rcc/rcc.cpp | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index 924f2904f0..4c463cf2a0 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -641,26 +641,31 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, QDir dir(file.filePath()); if (!alias.endsWith(slash)) alias += slash; + + QStringList filePaths; QDirIterator it(dir, QDirIterator::FollowSymlinks|QDirIterator::Subdirectories); while (it.hasNext()) { it.next(); - QFileInfo child(it.fileInfo()); - if (child.fileName() != QLatin1String(".") && child.fileName() != QLatin1String("..")) { - const bool arc = + if (it.fileName() == QLatin1String(".") + || it.fileName() == QLatin1String("..")) + continue; + filePaths.append(it.filePath()); + } + + // make rcc output deterministic + std::sort(filePaths.begin(), filePaths.end()); + + for (const QString &filePath : filePaths) { + QFileInfo child(filePath); + const bool arc = addFile(alias + child.fileName(), - RCCFileInfo(child.fileName(), - child, - language, - country, - child.isDir() ? RCCFileInfo::Directory : RCCFileInfo::NoFlags, - compressAlgo, - compressLevel, - compressThreshold, - m_noZstd) - ); - if (!arc) - m_failedResources.push_back(child.fileName()); - } + RCCFileInfo(child.fileName(), child, language, country, + child.isDir() ? RCCFileInfo::Directory + : RCCFileInfo::NoFlags, + compressAlgo, compressLevel, compressThreshold, + m_noZstd)); + if (!arc) + m_failedResources.push_back(child.fileName()); } } else if (listMode || file.isFile()) { const bool arc = -- cgit v1.2.3