diff options
-rw-r--r-- | src/plugins/projectexplorer/applicationlauncher.cpp | 22 | ||||
-rw-r--r-- | src/plugins/projectexplorer/applicationlauncher.h | 1 |
2 files changed, 18 insertions, 5 deletions
diff --git a/src/plugins/projectexplorer/applicationlauncher.cpp b/src/plugins/projectexplorer/applicationlauncher.cpp index 4c655def76e..40a9b6ac51d 100644 --- a/src/plugins/projectexplorer/applicationlauncher.cpp +++ b/src/plugins/projectexplorer/applicationlauncher.cpp @@ -43,6 +43,7 @@ #include <utils/qtcprocess.h> #include <QTextCodec> +#include <QTimer> #ifdef Q_OS_WIN #include <windows.h> @@ -80,7 +81,9 @@ struct ApplicationLauncherPrivate { QTextCodec::ConverterState m_outputCodecState; QTextCodec::ConverterState m_errorCodecState; // Keep track whether we need to emit a finished signal - bool m_processRunning; + bool m_processRunning = false; + + qint64 m_listeningPid = 0; }; ApplicationLauncherPrivate::ApplicationLauncherPrivate() : @@ -114,7 +117,7 @@ ApplicationLauncher::ApplicationLauncher(QObject *parent) d->m_consoleProcess.setSettings(Core::ICore::settings()); #endif connect(&d->m_consoleProcess, SIGNAL(processStarted()), - this, SIGNAL(processStarted())); + this, SLOT(handleProcessStarted())); connect(&d->m_consoleProcess, SIGNAL(processError(QString)), this, SLOT(consoleProcessError(QString))); connect(&d->m_consoleProcess, SIGNAL(processStopped(int,QProcess::ExitStatus)), @@ -288,19 +291,22 @@ void ApplicationLauncher::cannotRetrieveDebugOutput() void ApplicationLauncher::checkDebugOutput(qint64 pid, const QString &message) { - if (applicationPID() == pid) + if (d->m_listeningPid == pid) emit appendMessage(message, Utils::DebugFormat); } void ApplicationLauncher::processDone(int exitCode, QProcess::ExitStatus status) { - emit processExited(exitCode, status); + QTimer::singleShot(100, this, [this, exitCode, status]() { + d->m_listeningPid = 0; + emit processExited(exitCode, status); + }); } void ApplicationLauncher::bringToForeground() { emit bringToForegroundRequested(applicationPID()); - emit processStarted(); + handleProcessStarted(); } QString ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput() @@ -308,4 +314,10 @@ QString ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput() return tr("Cannot retrieve debugging output.") + QLatin1Char('\n'); } +void ApplicationLauncher::handleProcessStarted() +{ + d->m_listeningPid = applicationPID(); + emit processStarted(); +} + } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/applicationlauncher.h b/src/plugins/projectexplorer/applicationlauncher.h index f6d1d2f8d56..18541ac3eb5 100644 --- a/src/plugins/projectexplorer/applicationlauncher.h +++ b/src/plugins/projectexplorer/applicationlauncher.h @@ -81,6 +81,7 @@ signals: void error(QProcess::ProcessError error); private slots: + void handleProcessStarted(); void guiProcessError(); void consoleProcessError(const QString &error); void readStandardOutput(); |