Utils: Copy some SynchronousProcess function to QtcProcess

Start using it in Utils::Archive.

The idea is to merge SynchronousProcess into QtcProcess (or avoid its
use) to have fewer classes to make "remote-aware".

Change-Id: Ieb08f6f66eab63fd058b75e3bafa79bfbf140387
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2021-04-29 17:15:48 +02:00
parent fe8fbf1a4a
commit dcba96d16e
4 changed files with 32 additions and 10 deletions

View File

@@ -752,7 +752,7 @@ void QtcProcess::start()
#endif
// Note: Arguments set with setNativeArgs will be appended to the ones
// passed with start() below.
QProcess::start(command, QStringList());
QProcess::start(command, QStringList(), m_openMode);
} else {
if (!success) {
setErrorString(tr("Error in command line."));
@@ -761,7 +761,7 @@ void QtcProcess::start()
emit errorOccurred(QProcess::UnknownError);
return;
}
QProcess::start(command, arguments.toUnixArgs());
QProcess::start(command, arguments.toUnixArgs(), m_openMode);
}
if (m_synchronous)
@@ -1275,6 +1275,22 @@ void QtcProcess::setSynchronous(bool on)
m_synchronous = on;
}
void QtcProcess::setOpenMode(OpenMode mode)
{
m_openMode = mode;
}
bool QtcProcess::stopProcess()
{
if (state() == QProcess::NotRunning)
return true;
terminate();
if (waitForFinished(300))
return true;
kill();
return waitForFinished(300);
}
bool QtcProcess::ArgIterator::next()
{
// We delay the setting of m_prev so we can still delete the last argument