summaryrefslogtreecommitdiffstats
path: root/src/tools/macdeployqt/shared
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-08-05 17:58:47 +0200
committerMarc Mutz <marc.mutz@qt.io>2023-08-05 22:42:20 +0200
commitd7dc4d3ebb1e34cb5edb97d08e432ec12d02f7aa (patch)
tree706182524bd50fc373a324d0718652671ab9ed1c /src/tools/macdeployqt/shared
parenta631fef20f0ad59cd85e2247731641ece2338c30 (diff)
macdeployqt: port away from Q_FOREACH and mark the tool free of it
As a drive-by, fix a detach attempt in an existing ranged for-loop by making the container const, and don't re-construct the same QDir three times, just once, at beginning of the function. Change-Id: I5031c4b63dd939ae93dd119b01d1cad5e655f733 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/tools/macdeployqt/shared')
-rw-r--r--src/tools/macdeployqt/shared/shared.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/tools/macdeployqt/shared/shared.cpp b/src/tools/macdeployqt/shared/shared.cpp
index f637416cf2..c1dbd3dcf8 100644
--- a/src/tools/macdeployqt/shared/shared.cpp
+++ b/src/tools/macdeployqt/shared/shared.cpp
@@ -601,7 +601,7 @@ QStringList getBinaryDependencies(const QString executablePath,
} else if (trimmedLine.startsWith("@rpath/")) {
if (!rpathsLoaded) {
rpaths = getBinaryRPaths(path, true, executablePath);
- foreach (const QString &binaryPath, additionalBinariesContainingRpaths)
+ for (const QString &binaryPath : additionalBinariesContainingRpaths)
rpaths += getBinaryRPaths(binaryPath, true);
rpaths.removeDuplicates();
rpathsLoaded = true;
@@ -630,15 +630,16 @@ QStringList getBinaryDependencies(const QString executablePath,
bool recursiveCopy(const QString &sourcePath, const QString &destinationPath,
const QRegularExpression &ignoreRegExp = QRegularExpression())
{
- if (!QDir(sourcePath).exists())
+ const QDir sourceDir(sourcePath);
+ if (!sourceDir.exists())
return false;
QDir().mkpath(destinationPath);
LogNormal() << "copy:" << sourcePath << destinationPath;
- QStringList files = QDir(sourcePath).entryList(QStringList() << "*", QDir::Files | QDir::NoDotAndDotDot);
+ const QStringList files = sourceDir.entryList(QStringList() << "*", QDir::Files | QDir::NoDotAndDotDot);
const bool hasValidRegExp = ignoreRegExp.isValid() && ignoreRegExp.pattern().length() > 0;
- foreach (QString file, files) {
+ for (const QString &file : files) {
if (hasValidRegExp && ignoreRegExp.match(file).hasMatch())
continue;
const QString fileSourcePath = sourcePath + "/" + file;
@@ -646,7 +647,7 @@ bool recursiveCopy(const QString &sourcePath, const QString &destinationPath,
copyFilePrintStatus(fileSourcePath, fileDestinationPath);
}
- QStringList subdirs = QDir(sourcePath).entryList(QStringList() << "*", QDir::Dirs | QDir::NoDotAndDotDot);
+ const QStringList subdirs = sourceDir.entryList(QStringList() << "*", QDir::Dirs | QDir::NoDotAndDotDot);
for (const QString &dir : subdirs) {
recursiveCopy(sourcePath + "/" + dir, destinationPath + "/" + dir);
}
@@ -660,7 +661,9 @@ void recursiveCopyAndDeploy(const QString &appBundlePath, const QList<QString> &
LogNormal() << "copy:" << sourcePath << destinationPath;
const bool isDwarfPath = sourcePath.endsWith("DWARF");
- QStringList files = QDir(sourcePath).entryList(QStringList() << QStringLiteral("*"), QDir::Files | QDir::NoDotAndDotDot);
+ const QDir sourceDir(sourcePath);
+
+ const QStringList files = sourceDir.entryList(QStringList() << QStringLiteral("*"), QDir::Files | QDir::NoDotAndDotDot);
for (const QString &file : files) {
const QString fileSourcePath = sourcePath + u'/' + file;
@@ -706,7 +709,7 @@ void recursiveCopyAndDeploy(const QString &appBundlePath, const QList<QString> &
}
}
- QStringList subdirs = QDir(sourcePath).entryList(QStringList() << QStringLiteral("*"), QDir::Dirs | QDir::NoDotAndDotDot);
+ const QStringList subdirs = sourceDir.entryList(QStringList() << QStringLiteral("*"), QDir::Dirs | QDir::NoDotAndDotDot);
for (const QString &dir : subdirs) {
recursiveCopyAndDeploy(appBundlePath, rpaths, sourcePath + u'/' + dir, destinationPath + u'/' + dir);
}