diff options
author | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2022-11-15 14:41:32 +0200 |
---|---|---|
committer | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2022-11-24 09:45:53 +0200 |
commit | d4cf51ff3226e2cd8ea4ce0a0333fde890842479 (patch) | |
tree | 65251b44ab616df57123de1f3cc2ddae7ef35a01 /src/libs | |
parent | e58f99f35d7d50b1efa4c4bc68fc578a65666bf1 (diff) |
Execute operation: fix overwritten error string for crashed processes
When the process exited with QProcessWrapper::CrashExit, the code did
accidentally overwrite the associated error string later. The same would
have happened if the process could not be started, so fix that also.
Task-number: QTIFW-2875
Change-Id: Iae27be913ffa2b3f5dbeaf6db23b95f3a00377e1
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/installer/elevatedexecuteoperation.cpp | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/src/libs/installer/elevatedexecuteoperation.cpp b/src/libs/installer/elevatedexecuteoperation.cpp index fb1778fe0..5db0c887a 100644 --- a/src/libs/installer/elevatedexecuteoperation.cpp +++ b/src/libs/installer/elevatedexecuteoperation.cpp @@ -220,30 +220,29 @@ int ElevatedExecuteOperation::Private::run(QStringList &arguments, const Operati q->setValue(QLatin1String("ExitCode"), process->exitCode()); - if (process->exitStatus() == QProcessWrapper::CrashExit) { - q->setError(UserDefinedError); - q->setErrorString(tr("Program crashed: \"%1\"").arg(callstr)); - returnValue = Error; - } + if (success) { + const QByteArray standardErrorOutput = process->readAllStandardError(); + // in error case it would be useful to see something in verbose output + if (!standardErrorOutput.isEmpty()) + qCWarning(QInstaller::lcInstallerInstallLog).noquote() << standardErrorOutput; - if (!allowedExitCodes.contains(process->exitCode()) && returnValue != NeedsRerun) { - if (!needsRerunWithReplacedVariables(arguments, type)) { + if (process->exitStatus() == QProcessWrapper::CrashExit) { q->setError(UserDefinedError); - if (customErrorMessage.isEmpty()) { - q->setErrorString(tr("Execution failed (Unexpected exit code: %1): \"%2\"") - .arg(QString::number(process->exitCode()), callstr)); + q->setErrorString(tr("Program crashed: \"%1\"").arg(callstr)); + returnValue = Error; + } else if (!allowedExitCodes.contains(process->exitCode()) && returnValue != NeedsRerun) { + if (!needsRerunWithReplacedVariables(arguments, type)) { + q->setError(UserDefinedError); + if (customErrorMessage.isEmpty()) { + q->setErrorString(tr("Execution failed (Unexpected exit code: %1): \"%2\"") + .arg(QString::number(process->exitCode()), callstr)); + } else { + q->setErrorString(customErrorMessage); + } + returnValue = Error; } else { - q->setErrorString(customErrorMessage); + returnValue = NeedsRerun; } - - QByteArray standardErrorOutput = process->readAllStandardError(); - // in error case it would be useful to see something in verbose output - if (!standardErrorOutput.isEmpty()) - qCWarning(QInstaller::lcInstallerInstallLog).noquote() << standardErrorOutput; - - returnValue = Error; - } else { - returnValue = NeedsRerun; } } Q_ASSERT(process); |