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 <hjk@qt.io>
This commit is contained in:
Kai Koehne 2020-09-16 08:56:13 +02:00
parent 0da5726a43
commit 5d8f6beb46

View File

@ -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 =