Perforce: Use exitMessage() in synchronousProcess()

This is a standarized equivalent.

Change-Id: I609db7072e9eb645ca391c1eaca9a83dad40e460
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Jarek Kobus
2024-01-21 21:37:34 +01:00
parent c1e8688eea
commit ee13281a27

View File

@@ -1201,11 +1201,6 @@ static QString msgCrash()
return Tr::tr("The process terminated abnormally."); return Tr::tr("The process terminated abnormally.");
} }
static QString msgExitCode(int ex)
{
return Tr::tr("The process terminated with exit code %1.").arg(ex);
}
// Run using a SynchronousProcess, emitting signals to the message window // Run using a SynchronousProcess, emitting signals to the message window
PerforceResponse PerforcePluginPrivate::synchronousProcess(const FilePath &workingDir, PerforceResponse PerforcePluginPrivate::synchronousProcess(const FilePath &workingDir,
const QStringList &args, const QStringList &args,
@@ -1241,29 +1236,15 @@ PerforceResponse PerforcePluginPrivate::synchronousProcess(const FilePath &worki
process.setCommand({settings().p4BinaryPath(), args}); process.setCommand({settings().p4BinaryPath(), args});
process.runBlocking(EventLoopMode::On); process.runBlocking(EventLoopMode::On);
const auto result = process.result();
PerforceResponse response; PerforceResponse response;
response.error = true; response.error = result != ProcessResult::FinishedWithSuccess;
if (result == ProcessResult::FinishedWithError)
response.error = !(flags & IgnoreExitCode);
response.exitCode = process.exitCode(); response.exitCode = process.exitCode();
response.stdErr = process.cleanedStdErr(); response.stdErr = process.cleanedStdErr();
response.stdOut = process.cleanedStdOut(); response.stdOut = process.cleanedStdOut();
switch (process.result()) { response.message = process.exitMessage();
case ProcessResult::FinishedWithSuccess:
response.error = false;
break;
case ProcessResult::FinishedWithError:
response.message = msgExitCode(process.exitCode());
response.error = !(flags & IgnoreExitCode);
break;
case ProcessResult::TerminatedAbnormally:
response.message = msgCrash();
break;
case ProcessResult::StartFailed:
response.message = msgNotStarted(settings().p4BinaryPath());
break;
case ProcessResult::Hang:
response.message = msgCrash();
break;
}
return response; return response;
} }