Utils/Ssh: Move SshRemoteProces::isRunning() to QtcProcess base

... and use it on a few places.

Change-Id: Id2cea709e355a46821a720e593740ac032888ced
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2021-11-22 11:21:35 +01:00
parent 9c0bc16e94
commit e64ce914f9
11 changed files with 20 additions and 20 deletions

View File

@@ -315,7 +315,7 @@ QIODevice *ConnectionClient::ioDevice()
bool ConnectionClient::isProcessRunning(QtcProcess *process)
{
return process && process->state() == QProcess::Running;
return process && process->isRunning();
}
void ConnectionClient::connectStandardOutputAndError(QtcProcess *process) const

View File

@@ -97,7 +97,7 @@ struct SftpSession::SftpSessionPrivate
return;
if (pendingCommands.empty())
return;
QTC_ASSERT(sftpProc.state() == QProcess::Running, return);
QTC_ASSERT(sftpProc.isRunning(), return);
activeCommand = pendingCommands.dequeue();
// The second newline forces the prompt to appear after the command has finished.

View File

@@ -116,11 +116,6 @@ void SshRemoteProcess::start()
doStart();
}
bool SshRemoteProcess::isRunning() const
{
return state() == QProcess::Running;
}
Utils::CommandLine SshRemoteProcess::fullLocalCommandLine() const
{
Utils::CommandLine cmd{SshSettings::sshFilePath()};

View File

@@ -47,7 +47,6 @@ public:
void requestX11Forwarding(const QString &displayName);
void start();
bool isRunning() const;
Utils::CommandLine fullLocalCommandLine() const;
signals:

View File

@@ -1077,6 +1077,11 @@ QProcess::ProcessState QtcProcess::state() const
return d->m_process->state();
}
bool QtcProcess::isRunning() const
{
return state() == QProcess::Running;
}
QString QtcProcess::errorString() const
{
return d->m_process->errorString();

View File

@@ -171,6 +171,7 @@ public:
QProcess::ProcessError error() const;
QProcess::ProcessState state() const;
bool isRunning() const; // Short for state() == QProcess::Running.
QString errorString() const;
void setErrorString(const QString &str);

View File

@@ -128,7 +128,7 @@ static CreateAvdInfo createAvdCommand(const AndroidConfig &config, const CreateA
.arg(avdManagerTool.toString(), arguments.join(' '));
return result;
}
QTC_CHECK(proc.state() == QProcess::Running);
QTC_CHECK(proc.isRunning());
proc.write(QByteArray("yes\n")); // yes to "Do you wish to create a custom hardware profile"
auto start = chrono::steady_clock::now();
@@ -151,7 +151,7 @@ static CreateAvdInfo createAvdCommand(const AndroidConfig &config, const CreateA
// The exit code is always 0, so we need to check stderr
// For now assume that any output at all indicates a error
errorOutput = QString::fromLocal8Bit(proc.readAllStandardError());
if (proc.state() != QProcess::Running)
if (!proc.isRunning())
break;
// For a sane input and command, process should finish before timeout.

View File

@@ -719,7 +719,7 @@ void GdbEngine::runCommand(const DebuggerCommand &command)
QTC_ASSERT(false, return);
}
if (m_gdbProc.state() != QProcess::Running) {
if (!m_gdbProc.isRunning()) {
showMessage(QString("NO GDB PROCESS RUNNING, CMD IGNORED: %1 %2")
.arg(cmd.function).arg(state()));
if (cmd.callback) {
@@ -767,7 +767,7 @@ void GdbEngine::runCommand(const DebuggerCommand &command)
cmd.function = "python theDumper." + cmd.function + "(" + cmd.argsToPython() + ")";
}
QTC_ASSERT(m_gdbProc.state() == QProcess::Running, return);
QTC_ASSERT(m_gdbProc.isRunning(), return);
cmd.postTime = QTime::currentTime().msecsSinceStartOfDay();
m_commandForToken[token] = cmd;
@@ -1663,7 +1663,7 @@ void GdbEngine::handleInferiorShutdown(const DebuggerResponse &response)
// This happens when someone removed the binary behind our back.
// It is not really an error from a user's point of view.
showMessage("NOTE: " + msg);
} else if (m_gdbProc.state() == QProcess::Running) {
} else if (m_gdbProc.isRunning()) {
AsynchronousMessageBox::critical(tr("Failed to Shut Down Application"),
msgInferiorStopFailed(msg));
}

View File

@@ -126,7 +126,7 @@ void LldbEngine::executeDebuggerCommand(const QString &command)
void LldbEngine::runCommand(const DebuggerCommand &command)
{
if (m_lldbProc.state() != QProcess::Running) {
if (!m_lldbProc.isRunning()) {
// This can legally happen e.g. through a reloadModule()
// triggered by changes in view visibility.
showMessage(QString("NO LLDB PROCESS RUNNING, CMD IGNORED: %1 %2")
@@ -185,7 +185,7 @@ void LldbEngine::shutdownInferior()
void LldbEngine::shutdownEngine()
{
QTC_ASSERT(state() == EngineShutdownRequested, qDebug() << state());
if (m_lldbProc.state() == QProcess::Running)
if (m_lldbProc.isRunning())
m_lldbProc.terminate();
else
notifyEngineShutdownFinished();
@@ -193,7 +193,7 @@ void LldbEngine::shutdownEngine()
void LldbEngine::abortDebuggerProcess()
{
if (m_lldbProc.state() == QProcess::Running)
if (m_lldbProc.isRunning())
m_lldbProc.kill();
else
notifyEngineShutdownFinished();

View File

@@ -76,13 +76,13 @@ void PdbEngine::executeDebuggerCommand(const QString &command)
showMessage("PDB PROCESS NOT RUNNING, PLAIN CMD IGNORED: " + command);
return;
}
QTC_ASSERT(m_proc.state() == QProcess::Running, notifyEngineIll());
QTC_ASSERT(m_proc.isRunning(), notifyEngineIll());
postDirectCommand(command);
}
void PdbEngine::postDirectCommand(const QString &command)
{
QTC_ASSERT(m_proc.state() == QProcess::Running, notifyEngineIll());
QTC_ASSERT(m_proc.isRunning(), notifyEngineIll());
showMessage(command, LogInput);
m_proc.write(command.toUtf8() + '\n');
}
@@ -93,7 +93,7 @@ void PdbEngine::runCommand(const DebuggerCommand &cmd)
showMessage("IGNORED COMMAND: " + cmd.function);
return;
}
QTC_ASSERT(m_proc.state() == QProcess::Running, notifyEngineIll());
QTC_ASSERT(m_proc.isRunning(), notifyEngineIll());
QString command = "qdebug('" + cmd.function + "'," + cmd.argsToPython() + ")";
showMessage(command, LogInput);
m_proc.write(command.toUtf8() + '\n');

View File

@@ -887,7 +887,7 @@ void DockerDevicePrivate::startContainer()
m_shell->start();
m_shell->waitForStarted();
if (m_shell->state() != QProcess::Running) {
if (!m_shell->isRunning()) {
DockerPlugin::setGlobalDaemonState(false);
LOG("DOCKER SHELL FAILED");
return;