forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -43,6 +43,7 @@
|
|||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
|
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@@ -80,7 +81,9 @@ struct ApplicationLauncherPrivate {
|
|||||||
QTextCodec::ConverterState m_outputCodecState;
|
QTextCodec::ConverterState m_outputCodecState;
|
||||||
QTextCodec::ConverterState m_errorCodecState;
|
QTextCodec::ConverterState m_errorCodecState;
|
||||||
// Keep track whether we need to emit a finished signal
|
// Keep track whether we need to emit a finished signal
|
||||||
bool m_processRunning;
|
bool m_processRunning = false;
|
||||||
|
|
||||||
|
qint64 m_listeningPid = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
ApplicationLauncherPrivate::ApplicationLauncherPrivate() :
|
ApplicationLauncherPrivate::ApplicationLauncherPrivate() :
|
||||||
@@ -114,7 +117,7 @@ ApplicationLauncher::ApplicationLauncher(QObject *parent)
|
|||||||
d->m_consoleProcess.setSettings(Core::ICore::settings());
|
d->m_consoleProcess.setSettings(Core::ICore::settings());
|
||||||
#endif
|
#endif
|
||||||
connect(&d->m_consoleProcess, SIGNAL(processStarted()),
|
connect(&d->m_consoleProcess, SIGNAL(processStarted()),
|
||||||
this, SIGNAL(processStarted()));
|
this, SLOT(handleProcessStarted()));
|
||||||
connect(&d->m_consoleProcess, SIGNAL(processError(QString)),
|
connect(&d->m_consoleProcess, SIGNAL(processError(QString)),
|
||||||
this, SLOT(consoleProcessError(QString)));
|
this, SLOT(consoleProcessError(QString)));
|
||||||
connect(&d->m_consoleProcess, SIGNAL(processStopped(int,QProcess::ExitStatus)),
|
connect(&d->m_consoleProcess, SIGNAL(processStopped(int,QProcess::ExitStatus)),
|
||||||
@@ -288,19 +291,22 @@ void ApplicationLauncher::cannotRetrieveDebugOutput()
|
|||||||
|
|
||||||
void ApplicationLauncher::checkDebugOutput(qint64 pid, const QString &message)
|
void ApplicationLauncher::checkDebugOutput(qint64 pid, const QString &message)
|
||||||
{
|
{
|
||||||
if (applicationPID() == pid)
|
if (d->m_listeningPid == pid)
|
||||||
emit appendMessage(message, Utils::DebugFormat);
|
emit appendMessage(message, Utils::DebugFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationLauncher::processDone(int exitCode, QProcess::ExitStatus status)
|
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()
|
void ApplicationLauncher::bringToForeground()
|
||||||
{
|
{
|
||||||
emit bringToForegroundRequested(applicationPID());
|
emit bringToForegroundRequested(applicationPID());
|
||||||
emit processStarted();
|
handleProcessStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput()
|
QString ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput()
|
||||||
@@ -308,4 +314,10 @@ QString ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput()
|
|||||||
return tr("Cannot retrieve debugging output.") + QLatin1Char('\n');
|
return tr("Cannot retrieve debugging output.") + QLatin1Char('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ApplicationLauncher::handleProcessStarted()
|
||||||
|
{
|
||||||
|
d->m_listeningPid = applicationPID();
|
||||||
|
emit processStarted();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -81,6 +81,7 @@ signals:
|
|||||||
void error(QProcess::ProcessError error);
|
void error(QProcess::ProcessError error);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void handleProcessStarted();
|
||||||
void guiProcessError();
|
void guiProcessError();
|
||||||
void consoleProcessError(const QString &error);
|
void consoleProcessError(const QString &error);
|
||||||
void readStandardOutput();
|
void readStandardOutput();
|
||||||
|
Reference in New Issue
Block a user