forked from qt-creator/qt-creator
ApplicationLauncher: Also emit the exit status
And adjust the message in the appliation output to take the exit status into account. Change-Id: I1b7507fdc8ff6fa7ec3db48dba72ad723f124fc3 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
@@ -292,7 +292,7 @@ QmlEngine::QmlEngine(const DebuggerStartParameters &startParameters, DebuggerEng
|
||||
|
||||
|
||||
connect(&m_applicationLauncher,
|
||||
SIGNAL(processExited(int)),
|
||||
SIGNAL(processExited(int, QProcess::ExitStatus)),
|
||||
SLOT(disconnected()));
|
||||
connect(&m_applicationLauncher,
|
||||
SIGNAL(appendMessage(QString,Utils::OutputFormat)),
|
||||
@@ -597,7 +597,7 @@ void QmlEngine::startApplicationLauncher()
|
||||
void QmlEngine::stopApplicationLauncher()
|
||||
{
|
||||
if (m_applicationLauncher.isRunning()) {
|
||||
disconnect(&m_applicationLauncher, SIGNAL(processExited(int)),
|
||||
disconnect(&m_applicationLauncher, SIGNAL(processExited(int,QProcess::ExitStatus)),
|
||||
this, SLOT(disconnected()));
|
||||
m_applicationLauncher.stop();
|
||||
}
|
||||
|
||||
@@ -214,12 +214,14 @@ qint64 ApplicationLauncher::applicationPID() const
|
||||
void ApplicationLauncher::guiProcessError()
|
||||
{
|
||||
QString error;
|
||||
QProcess::ExitStatus status = QProcess::NormalExit;
|
||||
switch (d->m_guiProcess.error()) {
|
||||
case QProcess::FailedToStart:
|
||||
error = tr("Failed to start program. Path or permissions wrong?");
|
||||
break;
|
||||
case QProcess::Crashed:
|
||||
error = tr("The program has unexpectedly finished.");
|
||||
status = QProcess::CrashExit;
|
||||
break;
|
||||
default:
|
||||
error = tr("Some error has occurred while running the program.");
|
||||
@@ -227,7 +229,7 @@ void ApplicationLauncher::guiProcessError()
|
||||
emit appendMessage(error + QLatin1Char('\n'), Utils::ErrorMessageFormat);
|
||||
if (d->m_processRunning && !isRunning()) {
|
||||
d->m_processRunning = false;
|
||||
emit processExited(-1);
|
||||
emit processExited(-1, status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,7 +238,7 @@ void ApplicationLauncher::consoleProcessError(const QString &error)
|
||||
emit appendMessage(error + QLatin1Char('\n'), Utils::ErrorMessageFormat);
|
||||
if (d->m_processRunning && d->m_consoleProcess.applicationPID() == 0) {
|
||||
d->m_processRunning = false;
|
||||
emit processExited(-1);
|
||||
emit processExited(-1, QProcess::NormalExit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,9 +272,9 @@ void ApplicationLauncher::checkDebugOutput(qint64 pid, const QString &message)
|
||||
}
|
||||
#endif
|
||||
|
||||
void ApplicationLauncher::processDone(int exitCode, QProcess::ExitStatus)
|
||||
void ApplicationLauncher::processDone(int exitCode, QProcess::ExitStatus status)
|
||||
{
|
||||
emit processExited(exitCode);
|
||||
emit processExited(exitCode, status);
|
||||
}
|
||||
|
||||
void ApplicationLauncher::bringToForeground()
|
||||
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
signals:
|
||||
void appendMessage(const QString &message, Utils::OutputFormat format);
|
||||
void processStarted();
|
||||
void processExited(int exitCode);
|
||||
void processExited(int exitCode, QProcess::ExitStatus);
|
||||
void bringToForegroundRequested(qint64 pid);
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -84,8 +84,8 @@ LocalApplicationRunControl::LocalApplicationRunControl(LocalApplicationRunConfig
|
||||
this, SLOT(slotAppendMessage(QString,Utils::OutputFormat)));
|
||||
connect(&m_applicationLauncher, SIGNAL(processStarted()),
|
||||
this, SLOT(processStarted()));
|
||||
connect(&m_applicationLauncher, SIGNAL(processExited(int)),
|
||||
this, SLOT(processExited(int)));
|
||||
connect(&m_applicationLauncher, SIGNAL(processExited(int,QProcess::ExitStatus)),
|
||||
this, SLOT(processExited(int,QProcess::ExitStatus)));
|
||||
connect(&m_applicationLauncher, SIGNAL(bringToForegroundRequested(qint64)),
|
||||
this, SLOT(bringApplicationToForeground(qint64)));
|
||||
}
|
||||
@@ -141,12 +141,18 @@ void LocalApplicationRunControl::processStarted()
|
||||
setApplicationProcessHandle(ProcessHandle(m_applicationLauncher.applicationPID()));
|
||||
}
|
||||
|
||||
void LocalApplicationRunControl::processExited(int exitCode)
|
||||
void LocalApplicationRunControl::processExited(int exitCode, QProcess::ExitStatus status)
|
||||
{
|
||||
m_running = false;
|
||||
setApplicationProcessHandle(ProcessHandle());
|
||||
QString msg = tr("%1 exited with code %2\n")
|
||||
QString msg;
|
||||
if (status == QProcess::CrashExit) {
|
||||
msg = tr("%1 crashed\n")
|
||||
.arg(QDir::toNativeSeparators(m_executable));
|
||||
} else {
|
||||
msg = tr("%1 exited with code %2\n")
|
||||
.arg(QDir::toNativeSeparators(m_executable)).arg(exitCode);
|
||||
}
|
||||
appendMessage(msg, Utils::NormalMessageFormat);
|
||||
emit finished();
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
virtual QIcon icon() const;
|
||||
private slots:
|
||||
void processStarted();
|
||||
void processExited(int exitCode);
|
||||
void processExited(int exitCode, QProcess::ExitStatus status);
|
||||
void slotAppendMessage(const QString &err, Utils::OutputFormat isError);
|
||||
private:
|
||||
ProjectExplorer::ApplicationLauncher m_applicationLauncher;
|
||||
|
||||
@@ -111,19 +111,25 @@ void LocalQmlProfilerRunner::start()
|
||||
|
||||
m_launcher.setWorkingDirectory(m_configuration.workingDirectory);
|
||||
m_launcher.setEnvironment(m_configuration.environment);
|
||||
connect(&m_launcher, SIGNAL(processExited(int)), this, SLOT(spontaneousStop(int)));
|
||||
connect(&m_launcher, SIGNAL(processExited(int,QProcess::ExitStatus)),
|
||||
this, SLOT(spontaneousStop(int,QProcess::ExitStatus)));
|
||||
m_launcher.start(ProjectExplorer::ApplicationLauncher::Gui, m_configuration.executable,
|
||||
arguments);
|
||||
|
||||
emit started();
|
||||
}
|
||||
|
||||
void LocalQmlProfilerRunner::spontaneousStop(int exitCode)
|
||||
void LocalQmlProfilerRunner::spontaneousStop(int exitCode, QProcess::ExitStatus status)
|
||||
{
|
||||
if (QmlProfilerPlugin::debugOutput)
|
||||
if (QmlProfilerPlugin::debugOutput) {
|
||||
if (status == QProcess::CrashExit)
|
||||
qWarning("QmlProfiler: Application crashed.");
|
||||
else
|
||||
qWarning("QmlProfiler: Application exited (exit code %d).", exitCode);
|
||||
}
|
||||
|
||||
disconnect(&m_launcher, SIGNAL(processExited(int)), this, SLOT(spontaneousStop(int)));
|
||||
disconnect(&m_launcher, SIGNAL(processExited(int,QProcess::ExitStatus)),
|
||||
this, SLOT(spontaneousStop(int,QProcess::ExitStatus)));
|
||||
|
||||
emit stopped();
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
virtual quint16 debugPort() const;
|
||||
|
||||
private slots:
|
||||
void spontaneousStop(int exitCode);
|
||||
void spontaneousStop(int exitCode, QProcess::ExitStatus status);
|
||||
|
||||
private:
|
||||
LocalQmlProfilerRunner(const Configuration &configuration, QmlProfilerRunControl *engine);
|
||||
|
||||
@@ -71,8 +71,8 @@ QmlProjectRunControl::QmlProjectRunControl(QmlProjectRunConfiguration *runConfig
|
||||
|
||||
connect(&m_applicationLauncher, SIGNAL(appendMessage(QString,Utils::OutputFormat)),
|
||||
this, SLOT(slotAppendMessage(QString,Utils::OutputFormat)));
|
||||
connect(&m_applicationLauncher, SIGNAL(processExited(int)),
|
||||
this, SLOT(processExited(int)));
|
||||
connect(&m_applicationLauncher, SIGNAL(processExited(int,QProcess::ExitStatus)),
|
||||
this, SLOT(processExited(int,QProcess::ExitStatus)));
|
||||
connect(&m_applicationLauncher, SIGNAL(bringToForegroundRequested(qint64)),
|
||||
this, SLOT(slotBringApplicationToForeground(qint64)));
|
||||
}
|
||||
@@ -119,10 +119,15 @@ void QmlProjectRunControl::slotAppendMessage(const QString &line, Utils::OutputF
|
||||
appendMessage(line, format);
|
||||
}
|
||||
|
||||
void QmlProjectRunControl::processExited(int exitCode)
|
||||
void QmlProjectRunControl::processExited(int exitCode,QProcess::ExitStatus status)
|
||||
{
|
||||
QString msg = tr("%1 exited with code %2\n")
|
||||
QString msg;
|
||||
if (status == QProcess::CrashExit)
|
||||
msg = tr("%1 crashed\n") .arg(QDir::toNativeSeparators(m_executable));
|
||||
else
|
||||
msg = tr("%1 exited with code %2\n")
|
||||
.arg(QDir::toNativeSeparators(m_executable)).arg(exitCode);
|
||||
|
||||
appendMessage(msg, exitCode ? Utils::ErrorMessageFormat : Utils::NormalMessageFormat);
|
||||
emit finished();
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
QString mainQmlFile() const;
|
||||
|
||||
private slots:
|
||||
void processExited(int exitCode);
|
||||
void processExited(int exitCode, QProcess::ExitStatus status);
|
||||
void slotBringApplicationToForeground(qint64 pid);
|
||||
void slotAppendMessage(const QString &line, Utils::OutputFormat);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user