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,
|
connect(&m_applicationLauncher,
|
||||||
SIGNAL(processExited(int)),
|
SIGNAL(processExited(int, QProcess::ExitStatus)),
|
||||||
SLOT(disconnected()));
|
SLOT(disconnected()));
|
||||||
connect(&m_applicationLauncher,
|
connect(&m_applicationLauncher,
|
||||||
SIGNAL(appendMessage(QString,Utils::OutputFormat)),
|
SIGNAL(appendMessage(QString,Utils::OutputFormat)),
|
||||||
@@ -597,7 +597,7 @@ void QmlEngine::startApplicationLauncher()
|
|||||||
void QmlEngine::stopApplicationLauncher()
|
void QmlEngine::stopApplicationLauncher()
|
||||||
{
|
{
|
||||||
if (m_applicationLauncher.isRunning()) {
|
if (m_applicationLauncher.isRunning()) {
|
||||||
disconnect(&m_applicationLauncher, SIGNAL(processExited(int)),
|
disconnect(&m_applicationLauncher, SIGNAL(processExited(int,QProcess::ExitStatus)),
|
||||||
this, SLOT(disconnected()));
|
this, SLOT(disconnected()));
|
||||||
m_applicationLauncher.stop();
|
m_applicationLauncher.stop();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,12 +214,14 @@ qint64 ApplicationLauncher::applicationPID() const
|
|||||||
void ApplicationLauncher::guiProcessError()
|
void ApplicationLauncher::guiProcessError()
|
||||||
{
|
{
|
||||||
QString error;
|
QString error;
|
||||||
|
QProcess::ExitStatus status = QProcess::NormalExit;
|
||||||
switch (d->m_guiProcess.error()) {
|
switch (d->m_guiProcess.error()) {
|
||||||
case QProcess::FailedToStart:
|
case QProcess::FailedToStart:
|
||||||
error = tr("Failed to start program. Path or permissions wrong?");
|
error = tr("Failed to start program. Path or permissions wrong?");
|
||||||
break;
|
break;
|
||||||
case QProcess::Crashed:
|
case QProcess::Crashed:
|
||||||
error = tr("The program has unexpectedly finished.");
|
error = tr("The program has unexpectedly finished.");
|
||||||
|
status = QProcess::CrashExit;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error = tr("Some error has occurred while running the program.");
|
error = tr("Some error has occurred while running the program.");
|
||||||
@@ -227,7 +229,7 @@ void ApplicationLauncher::guiProcessError()
|
|||||||
emit appendMessage(error + QLatin1Char('\n'), Utils::ErrorMessageFormat);
|
emit appendMessage(error + QLatin1Char('\n'), Utils::ErrorMessageFormat);
|
||||||
if (d->m_processRunning && !isRunning()) {
|
if (d->m_processRunning && !isRunning()) {
|
||||||
d->m_processRunning = false;
|
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);
|
emit appendMessage(error + QLatin1Char('\n'), Utils::ErrorMessageFormat);
|
||||||
if (d->m_processRunning && d->m_consoleProcess.applicationPID() == 0) {
|
if (d->m_processRunning && d->m_consoleProcess.applicationPID() == 0) {
|
||||||
d->m_processRunning = false;
|
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
|
#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()
|
void ApplicationLauncher::bringToForeground()
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void appendMessage(const QString &message, Utils::OutputFormat format);
|
void appendMessage(const QString &message, Utils::OutputFormat format);
|
||||||
void processStarted();
|
void processStarted();
|
||||||
void processExited(int exitCode);
|
void processExited(int exitCode, QProcess::ExitStatus);
|
||||||
void bringToForegroundRequested(qint64 pid);
|
void bringToForegroundRequested(qint64 pid);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|||||||
@@ -84,8 +84,8 @@ LocalApplicationRunControl::LocalApplicationRunControl(LocalApplicationRunConfig
|
|||||||
this, SLOT(slotAppendMessage(QString,Utils::OutputFormat)));
|
this, SLOT(slotAppendMessage(QString,Utils::OutputFormat)));
|
||||||
connect(&m_applicationLauncher, SIGNAL(processStarted()),
|
connect(&m_applicationLauncher, SIGNAL(processStarted()),
|
||||||
this, SLOT(processStarted()));
|
this, SLOT(processStarted()));
|
||||||
connect(&m_applicationLauncher, SIGNAL(processExited(int)),
|
connect(&m_applicationLauncher, SIGNAL(processExited(int,QProcess::ExitStatus)),
|
||||||
this, SLOT(processExited(int)));
|
this, SLOT(processExited(int,QProcess::ExitStatus)));
|
||||||
connect(&m_applicationLauncher, SIGNAL(bringToForegroundRequested(qint64)),
|
connect(&m_applicationLauncher, SIGNAL(bringToForegroundRequested(qint64)),
|
||||||
this, SLOT(bringApplicationToForeground(qint64)));
|
this, SLOT(bringApplicationToForeground(qint64)));
|
||||||
}
|
}
|
||||||
@@ -141,12 +141,18 @@ void LocalApplicationRunControl::processStarted()
|
|||||||
setApplicationProcessHandle(ProcessHandle(m_applicationLauncher.applicationPID()));
|
setApplicationProcessHandle(ProcessHandle(m_applicationLauncher.applicationPID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalApplicationRunControl::processExited(int exitCode)
|
void LocalApplicationRunControl::processExited(int exitCode, QProcess::ExitStatus status)
|
||||||
{
|
{
|
||||||
m_running = false;
|
m_running = false;
|
||||||
setApplicationProcessHandle(ProcessHandle());
|
setApplicationProcessHandle(ProcessHandle());
|
||||||
QString msg = tr("%1 exited with code %2\n")
|
QString msg;
|
||||||
.arg(QDir::toNativeSeparators(m_executable)).arg(exitCode);
|
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);
|
appendMessage(msg, Utils::NormalMessageFormat);
|
||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public:
|
|||||||
virtual QIcon icon() const;
|
virtual QIcon icon() const;
|
||||||
private slots:
|
private slots:
|
||||||
void processStarted();
|
void processStarted();
|
||||||
void processExited(int exitCode);
|
void processExited(int exitCode, QProcess::ExitStatus status);
|
||||||
void slotAppendMessage(const QString &err, Utils::OutputFormat isError);
|
void slotAppendMessage(const QString &err, Utils::OutputFormat isError);
|
||||||
private:
|
private:
|
||||||
ProjectExplorer::ApplicationLauncher m_applicationLauncher;
|
ProjectExplorer::ApplicationLauncher m_applicationLauncher;
|
||||||
|
|||||||
@@ -111,19 +111,25 @@ void LocalQmlProfilerRunner::start()
|
|||||||
|
|
||||||
m_launcher.setWorkingDirectory(m_configuration.workingDirectory);
|
m_launcher.setWorkingDirectory(m_configuration.workingDirectory);
|
||||||
m_launcher.setEnvironment(m_configuration.environment);
|
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,
|
m_launcher.start(ProjectExplorer::ApplicationLauncher::Gui, m_configuration.executable,
|
||||||
arguments);
|
arguments);
|
||||||
|
|
||||||
emit started();
|
emit started();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalQmlProfilerRunner::spontaneousStop(int exitCode)
|
void LocalQmlProfilerRunner::spontaneousStop(int exitCode, QProcess::ExitStatus status)
|
||||||
{
|
{
|
||||||
if (QmlProfilerPlugin::debugOutput)
|
if (QmlProfilerPlugin::debugOutput) {
|
||||||
qWarning("QmlProfiler: Application exited (exit code %d).", exitCode);
|
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();
|
emit stopped();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public:
|
|||||||
virtual quint16 debugPort() const;
|
virtual quint16 debugPort() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void spontaneousStop(int exitCode);
|
void spontaneousStop(int exitCode, QProcess::ExitStatus status);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LocalQmlProfilerRunner(const Configuration &configuration, QmlProfilerRunControl *engine);
|
LocalQmlProfilerRunner(const Configuration &configuration, QmlProfilerRunControl *engine);
|
||||||
|
|||||||
@@ -71,8 +71,8 @@ QmlProjectRunControl::QmlProjectRunControl(QmlProjectRunConfiguration *runConfig
|
|||||||
|
|
||||||
connect(&m_applicationLauncher, SIGNAL(appendMessage(QString,Utils::OutputFormat)),
|
connect(&m_applicationLauncher, SIGNAL(appendMessage(QString,Utils::OutputFormat)),
|
||||||
this, SLOT(slotAppendMessage(QString,Utils::OutputFormat)));
|
this, SLOT(slotAppendMessage(QString,Utils::OutputFormat)));
|
||||||
connect(&m_applicationLauncher, SIGNAL(processExited(int)),
|
connect(&m_applicationLauncher, SIGNAL(processExited(int,QProcess::ExitStatus)),
|
||||||
this, SLOT(processExited(int)));
|
this, SLOT(processExited(int,QProcess::ExitStatus)));
|
||||||
connect(&m_applicationLauncher, SIGNAL(bringToForegroundRequested(qint64)),
|
connect(&m_applicationLauncher, SIGNAL(bringToForegroundRequested(qint64)),
|
||||||
this, SLOT(slotBringApplicationToForeground(qint64)));
|
this, SLOT(slotBringApplicationToForeground(qint64)));
|
||||||
}
|
}
|
||||||
@@ -119,10 +119,15 @@ void QmlProjectRunControl::slotAppendMessage(const QString &line, Utils::OutputF
|
|||||||
appendMessage(line, format);
|
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;
|
||||||
.arg(QDir::toNativeSeparators(m_executable)).arg(exitCode);
|
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);
|
appendMessage(msg, exitCode ? Utils::ErrorMessageFormat : Utils::NormalMessageFormat);
|
||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public:
|
|||||||
QString mainQmlFile() const;
|
QString mainQmlFile() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void processExited(int exitCode);
|
void processExited(int exitCode, QProcess::ExitStatus status);
|
||||||
void slotBringApplicationToForeground(qint64 pid);
|
void slotBringApplicationToForeground(qint64 pid);
|
||||||
void slotAppendMessage(const QString &line, Utils::OutputFormat);
|
void slotAppendMessage(const QString &line, Utils::OutputFormat);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user