forked from qt-creator/qt-creator
ProjectExplorer: Use one function for done() in application launcher
This only shifts the 'if' down one level. Change-Id: I2c049d9a38d786698c728e88d15b0129eba35aed Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -75,16 +75,15 @@ public:
|
||||
|
||||
void handleStandardOutput();
|
||||
void handleStandardError();
|
||||
void handleDone();
|
||||
|
||||
// Local
|
||||
void handleLocalDone();
|
||||
void cannotRetrieveLocalDebugOutput();
|
||||
void checkLocalDebugOutput(qint64 pid, const QString &message);
|
||||
qint64 applicationPID() const;
|
||||
bool isRunning() const;
|
||||
|
||||
// Remote
|
||||
void handleRemoteDone();
|
||||
void doReportError(const QString &message,
|
||||
QProcess::ProcessError error = QProcess::FailedToStart);
|
||||
void setFinished();
|
||||
@@ -240,9 +239,11 @@ QProcess::ProcessError ApplicationLauncher::error() const
|
||||
return d->m_remoteError;
|
||||
}
|
||||
|
||||
void ApplicationLauncherPrivate::handleLocalDone()
|
||||
void ApplicationLauncherPrivate::handleDone()
|
||||
{
|
||||
const QProcess::ProcessError error = m_process->error();
|
||||
|
||||
if (m_isLocal) {
|
||||
if (error == QProcess::UnknownError) {
|
||||
m_exitCode = m_process->exitCode();
|
||||
m_exitStatus = m_process->exitStatus();
|
||||
@@ -259,7 +260,7 @@ void ApplicationLauncherPrivate::handleLocalDone()
|
||||
}
|
||||
} else {
|
||||
QString errorString;
|
||||
switch (m_process->error()) {
|
||||
switch (error) {
|
||||
case QProcess::FailedToStart:
|
||||
errorString = ApplicationLauncher::tr("Failed to start program. Path or permissions wrong?");
|
||||
break;
|
||||
@@ -278,6 +279,17 @@ void ApplicationLauncherPrivate::handleLocalDone()
|
||||
}
|
||||
}
|
||||
emit q->errorOccurred(error);
|
||||
|
||||
} else {
|
||||
QTC_ASSERT(m_state == Run, return);
|
||||
if (error == QProcess::FailedToStart) {
|
||||
doReportError(ApplicationLauncher::tr("Application failed to start: %1")
|
||||
.arg(m_process->errorString()));
|
||||
} else if (m_process->exitStatus() == QProcess::CrashExit) {
|
||||
doReportError(m_process->errorString(), QProcess::Crashed);
|
||||
}
|
||||
setFinished();
|
||||
}
|
||||
}
|
||||
|
||||
void ApplicationLauncherPrivate::handleStandardOutput()
|
||||
@@ -336,9 +348,6 @@ void ApplicationLauncherPrivate::start()
|
||||
if (m_isLocal) {
|
||||
m_process.reset(new QtcProcess(this));
|
||||
|
||||
connect(m_process.get(), &QtcProcess::done,
|
||||
this, &ApplicationLauncherPrivate::handleLocalDone);
|
||||
|
||||
// Work around QTBUG-17529 (QtDeclarative fails with 'File name case mismatch' ...)
|
||||
const FilePath fixedPath = m_runnable.workingDirectory.normalizedPathName();
|
||||
m_process->setWorkingDirectory(fixedPath);
|
||||
@@ -390,8 +399,6 @@ void ApplicationLauncherPrivate::start()
|
||||
m_stopRequested = false;
|
||||
|
||||
m_process.reset(m_runnable.device->createProcess(this));
|
||||
connect(m_process.get(), &QtcProcess::done,
|
||||
this, &ApplicationLauncherPrivate::handleRemoteDone);
|
||||
m_process->setCommand(m_runnable.command);
|
||||
m_process->setWorkingDirectory(m_runnable.workingDirectory);
|
||||
m_process->setRemoteEnvironment(m_runnable.environment);
|
||||
@@ -404,6 +411,7 @@ void ApplicationLauncherPrivate::start()
|
||||
m_outputCodec = QTextCodec::codecForName("utf8");
|
||||
|
||||
connect(m_process.get(), &QtcProcess::started, q, &ApplicationLauncher::started);
|
||||
connect(m_process.get(), &QtcProcess::done, this, &ApplicationLauncherPrivate::handleDone);
|
||||
|
||||
m_process->setProcessChannelMode(m_processChannelMode);
|
||||
if (m_processChannelMode == QProcess::SeparateChannels) {
|
||||
@@ -430,18 +438,6 @@ void ApplicationLauncherPrivate::setFinished()
|
||||
emit q->finished();
|
||||
}
|
||||
|
||||
void ApplicationLauncherPrivate::handleRemoteDone()
|
||||
{
|
||||
QTC_ASSERT(m_state == Run, return);
|
||||
if (m_process->error() == QProcess::FailedToStart) {
|
||||
doReportError(ApplicationLauncher::tr("Application failed to start: %1")
|
||||
.arg(m_process->errorString()));
|
||||
} else if (m_process->exitStatus() == QProcess::CrashExit) {
|
||||
doReportError(m_process->errorString(), QProcess::Crashed);
|
||||
}
|
||||
setFinished();
|
||||
}
|
||||
|
||||
void ApplicationLauncherPrivate::doReportError(const QString &message, QProcess::ProcessError error)
|
||||
{
|
||||
m_remoteErrorString = message;
|
||||
|
Reference in New Issue
Block a user