ProjectExplorer: Inline some ApplicationLauncherPrivate functions

To help with future re-organization.

Change-Id: I8fd87d3e792f8e5be86aaa0bc9754eae9b92b328
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2022-04-28 14:02:07 +02:00
parent b3c4d2c1aa
commit 4d8ef8d6e1

View File

@@ -69,7 +69,11 @@ class ApplicationLauncherPrivate : public QObject
public:
enum State { Inactive, Run };
explicit ApplicationLauncherPrivate(ApplicationLauncher *parent);
~ApplicationLauncherPrivate() override { setFinished(); }
~ApplicationLauncherPrivate() override {
if (m_state == Run)
emit q->finished();
}
void start();
void stop();
@@ -84,10 +88,6 @@ public:
qint64 applicationPID() const;
bool isRunning() const;
// Remote
void doReportError(QProcess::ProcessError error = QProcess::FailedToStart);
void setFinished();
public:
ApplicationLauncher *q;
@@ -274,11 +274,14 @@ void ApplicationLauncherPrivate::handleDone()
} else {
QTC_ASSERT(m_state == Run, return);
if (m_resultData.m_error == QProcess::FailedToStart) {
doReportError();
} else if (m_process->exitStatus() == QProcess::CrashExit) {
doReportError(QProcess::Crashed);
m_resultData.m_exitStatus = QProcess::CrashExit;
emit q->errorOccurred(m_resultData.m_error);
} else if (m_resultData.m_exitStatus == QProcess::CrashExit) {
m_resultData.m_error = QProcess::Crashed;
emit q->errorOccurred(m_resultData.m_error);
}
setFinished();
m_state = Inactive;
emit q->finished();
}
}
@@ -366,28 +369,34 @@ void ApplicationLauncherPrivate::start()
} else {
QTC_ASSERT(m_state == Inactive, return);
m_state = Run;
if (!m_runnable.device) {
m_resultData.m_errorString = ApplicationLauncher::tr("Cannot run: No device.");
doReportError();
setFinished();
m_resultData.m_error = QProcess::FailedToStart;
m_resultData.m_exitStatus = QProcess::CrashExit;
emit q->errorOccurred(QProcess::FailedToStart);
emit q->finished();
return;
}
if (!m_runnable.device->canCreateProcess()) {
m_resultData.m_errorString =ApplicationLauncher::tr("Cannot run: Device is not able to create processes.");
doReportError();
setFinished();
m_resultData.m_error = QProcess::FailedToStart;
m_resultData.m_exitStatus = QProcess::CrashExit;
emit q->errorOccurred(QProcess::FailedToStart);
emit q->finished();
return;
}
if (!m_runnable.device->isEmptyCommandAllowed() && m_runnable.command.isEmpty()) {
m_resultData.m_errorString = ApplicationLauncher::tr("Cannot run: No command given.");
doReportError();
setFinished();
m_resultData.m_error = QProcess::FailedToStart;
m_resultData.m_exitStatus = QProcess::CrashExit;
emit q->errorOccurred(QProcess::FailedToStart);
emit q->finished();
return;
}
m_state = Run;
m_stopRequested = false;
m_process.reset(m_runnable.device->createProcess(this));
@@ -419,20 +428,4 @@ void ApplicationLauncherPrivate::start()
m_process->start();
}
void ApplicationLauncherPrivate::setFinished()
{
if (m_state == Inactive)
return;
m_state = Inactive;
emit q->finished();
}
void ApplicationLauncherPrivate::doReportError(QProcess::ProcessError error)
{
m_resultData.m_error = error;
m_resultData.m_exitStatus = QProcess::CrashExit;
emit q->errorOccurred(error);
}
} // namespace ProjectExplorer