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