summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-11-06 09:39:19 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-11-06 17:47:04 +0000
commitefc1a79ab1a637ebba1cd739b9c1aed28ae79d0b (patch)
treec4a50ed37333536a3ede8a70a53551021b5637be
parentc02a01b6f5ded6b5df198403b16ba9365aa2ff51 (diff)
Fix lupdate leaking a temporary file when hitting on a .pro file error
The call to exit() in runQtTool() called from createProjectDescription() left the file behind. Factor out helpers that return the exit code and exit() in createProjectDescription(). Fixes: QTBUG-118769 Pick-to: 6.5 Change-Id: I957e71e5860d66ca4c384669923cf5b82abf4ef5 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 20ebadd336805769de8ff5be29d24f07ab61efbb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/linguist/shared/runqttool.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/linguist/shared/runqttool.cpp b/src/linguist/shared/runqttool.cpp
index 13d8bb07c..f0be67c8d 100644
--- a/src/linguist/shared/runqttool.cpp
+++ b/src/linguist/shared/runqttool.cpp
@@ -60,8 +60,8 @@ static QString commandLineForSystem(const QString &program,
+ shellQuoted(arguments).join(QLatin1Char(' '));
}
-void runQtTool(const QString &toolName, const QStringList &arguments,
- QLibraryInfo::LibraryPath location)
+static int runQtToolHelper(const QString &toolName, const QStringList &arguments,
+ QLibraryInfo::LibraryPath location)
{
int exitCode = 0;
const QString commandLine = commandLineForSystem(qtToolFilePath(toolName, location), arguments);
@@ -73,13 +73,27 @@ void runQtTool(const QString &toolName, const QStringList &arguments,
#else
exitCode = std::system(qPrintable(commandLine));
#endif
+ return exitCode;
+}
+
+void runQtTool(const QString &toolName, const QStringList &arguments,
+ QLibraryInfo::LibraryPath location)
+{
+ const int exitCode = runQtToolHelper(toolName, arguments, location);
if (exitCode != 0)
exit(exitCode);
}
+static int runInternalQtToolHelper(const QString &toolName, const QStringList &arguments)
+{
+ return runQtToolHelper(toolName, arguments, QLibraryInfo::LibraryExecutablesPath);
+}
+
void runInternalQtTool(const QString &toolName, const QStringList &arguments)
{
- runQtTool(toolName, arguments, QLibraryInfo::LibraryExecutablesPath);
+ const int exitCode = runInternalQtToolHelper(toolName, arguments);
+ if (exitCode != 0)
+ exit(exitCode);
}
std::unique_ptr<QTemporaryFile> createProjectDescription(QStringList args)
@@ -91,6 +105,10 @@ std::unique_ptr<QTemporaryFile> createProjectDescription(QStringList args)
}
file->close();
args << QStringLiteral("-out") << file->fileName();
- runInternalQtTool(QStringLiteral("lprodump"), args);
+ const int exitCode = runInternalQtToolHelper(QStringLiteral("lprodump"), args);
+ if (exitCode != 0) {
+ file.reset();
+ exit(exitCode);
+ }
return file;
}