diff options
author | Tobias Hunger <tobias.hunger@theqtcompany.com> | 2016-02-17 16:31:20 +0100 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@theqtcompany.com> | 2016-02-29 12:51:39 +0000 |
commit | a286c8da44e1ad2afdae83dc2fc880598272de57 (patch) | |
tree | c8e54f65bc19126590123b03ad0f070409dbc8fc | |
parent | 049675077a0b12e83811fef8641503038d0491d9 (diff) | |
download | qt-creator-a286c8da44e1ad2afdae83dc2fc880598272de57.tar.gz |
ApplicationLaucher: Catch late WinDebug messages
Catch and display messages received from WinDebug interface, even
for a short while after the process has already finished.
This can apparently happen, e.g. when doing a qDebug right before
the application ends (and QT_LOGGING_TO_CONSOLE is not 1, the
application is being run in GUI mode, on windows).
Task-number: QTCREATORBUG-15546
Change-Id: I37a015da89fc409234adeb597171fa328f50c14d
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
-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 4c655def76..40a9b6ac51 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 f6d1d2f8d5..18541ac3eb 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(); |