summaryrefslogtreecommitdiffstats
path: root/src/tools/rcc/rcc.cpp
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@qt.io>2020-09-16 08:56:13 +0200
committerKai Koehne <kai.koehne@qt.io>2020-09-25 10:12:04 +0200
commit263694a539d5efe1902e4c6559b5d971b4ed0ed2 (patch)
tree9f741694c6f5ca583c1d36650443712d16c67f87 /src/tools/rcc/rcc.cpp
parent0790249acf069d89f6debc98eab4caf5b8ca2712 (diff)
rcc: Make output deterministic for directories
QDirIterator is documented to be non-deterministic. Fixes: QTBUG-86675 Change-Id: I4161871a409bbaf85347ee6a60ef1189f56a1b22 Reviewed-by: hjk <hjk@qt.io> (cherry picked from commit 5d8f6beb4640d64a262fa918b47e0073ea39fbda)
Diffstat (limited to 'src/tools/rcc/rcc.cpp')
-rw-r--r--src/tools/rcc/rcc.cpp37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp
index 7188c81300..c5e3d2ae4c 100644
--- a/src/tools/rcc/rcc.cpp
+++ b/src/tools/rcc/rcc.cpp
@@ -637,25 +637,30 @@ 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 =
- addFile(alias + child.fileName(),
- RCCFileInfo(child.fileName(),
- child,
- language,
- country,
- child.isDir() ? RCCFileInfo::Directory : RCCFileInfo::NoFlags,
- compressAlgo,
- compressLevel,
- compressThreshold)
- );
- if (!arc)
- m_failedResources.push_back(child.fileName());
- }
+ 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));
+ if (!arc)
+ m_failedResources.push_back(child.fileName());
}
} else if (listMode || file.isFile()) {
const bool arc =