forked from qt-creator/qt-creator
Utils: Make process results accessible through QtcProcess object
The result is fully stored in the object anyway. Using the extra SynchronousProcessResponse structure only causes copies of the data and complicates access on the user side in a lot of cases. The result bits are now also accessible individually. There's obvious room for follow-up changes on the topic, e.g. ShellCommand::runCommand's parameter list could shrink to just a SynchronousProcess parameter. Change-Id: I45aa7eb23832340be06905929280c012e1217263 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -204,8 +204,8 @@ public:
|
||||
{
|
||||
if (cmd == DiffCommand) {
|
||||
return [](int code) {
|
||||
return (code < 0 || code > 2) ? SynchronousProcessResponse::FinishedError
|
||||
: SynchronousProcessResponse::Finished;
|
||||
return (code < 0 || code > 2) ? QtcProcess::FinishedError
|
||||
: QtcProcess::Finished;
|
||||
};
|
||||
}
|
||||
return {};
|
||||
@@ -1446,28 +1446,31 @@ CvsResponse CvsPluginPrivate::runCvs(const QString &workingDirectory,
|
||||
return response;
|
||||
}
|
||||
// Run, connect stderr to the output window
|
||||
const SynchronousProcessResponse sp_resp =
|
||||
runVcs(workingDirectory, {executable, m_settings.addOptions(arguments)},
|
||||
timeOutS, flags, outputCodec);
|
||||
SynchronousProcess proc;
|
||||
|
||||
VcsCommand command(workingDirectory, Environment::systemEnvironment());
|
||||
command.addFlags(flags);
|
||||
command.setCodec(outputCodec);
|
||||
command.runCommand(proc, {executable, m_settings.addOptions(arguments)}, timeOutS);
|
||||
|
||||
response.result = CvsResponse::OtherError;
|
||||
response.stdErr = sp_resp.stdErr();
|
||||
response.stdOut = sp_resp.stdOut();
|
||||
switch (sp_resp.result) {
|
||||
case SynchronousProcessResponse::Finished:
|
||||
response.stdErr = proc.stdErr();
|
||||
response.stdOut = proc.stdOut();
|
||||
switch (proc.result()) {
|
||||
case QtcProcess::Finished:
|
||||
response.result = CvsResponse::Ok;
|
||||
break;
|
||||
case SynchronousProcessResponse::FinishedError:
|
||||
case QtcProcess::FinishedError:
|
||||
response.result = CvsResponse::NonNullExitCode;
|
||||
break;
|
||||
case SynchronousProcessResponse::TerminatedAbnormally:
|
||||
case SynchronousProcessResponse::StartFailed:
|
||||
case SynchronousProcessResponse::Hang:
|
||||
case QtcProcess::TerminatedAbnormally:
|
||||
case QtcProcess::StartFailed:
|
||||
case QtcProcess::Hang:
|
||||
break;
|
||||
}
|
||||
|
||||
if (response.result != CvsResponse::Ok)
|
||||
response.message = sp_resp.exitMessage(executable.toString(), timeOutS);
|
||||
response.message = proc.exitMessage(executable.toString(), timeOutS);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user