Process: Add setRunData() helper

It allows to set command/workingDir/env in one go.

Fix condition for setCommand() to match the one for setWorkingDir().

Change-Id: I0aa4639f3357c387a0fe8da321e94e34a3ea232d
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2023-08-16 20:08:48 +02:00
parent 8cf7ac4ac7
commit f4eb25ccec
2 changed files with 34 additions and 14 deletions

View File

@@ -1183,10 +1183,25 @@ const Environment &Process::controlEnvironment() const
return d->m_setup.m_controlEnvironment;
}
void Process::setRunData(const ProcessRunData &data)
{
if (data.workingDirectory.needsDevice() && data.command.executable().needsDevice()) {
QTC_CHECK(data.workingDirectory.isSameDevice(data.command.executable()));
}
d->m_setup.m_commandLine = data.command;
d->m_setup.m_workingDirectory = data.workingDirectory;
d->m_setup.m_environment = data.environment;
}
ProcessRunData Process::runData() const
{
return {d->m_setup.m_commandLine, d->m_setup.m_workingDirectory, d->m_setup.m_environment};
}
void Process::setCommand(const CommandLine &cmdLine)
{
if (d->m_setup.m_workingDirectory.needsDevice() && cmdLine.executable().needsDevice()) {
QTC_CHECK(d->m_setup.m_workingDirectory.host() == cmdLine.executable().host());
QTC_CHECK(d->m_setup.m_workingDirectory.isSameDevice(cmdLine.executable()));
}
d->m_setup.m_commandLine = cmdLine;
}