From fbd9ae120fb53e36b63e75b68408edd8d2b2af7f Mon Sep 17 00:00:00 2001 From: Daniel Teske <daniel.teske@nokia.com> Date: Wed, 24 Aug 2011 13:00:57 +0200 Subject: [PATCH] Enable attaching to console processes The pid is not immediately set for console processes. setApplicationHandle needs to be called in response to the ConsoleProcess::processStarted signal. Change-Id: I957d829936c33eff004f348a832d95f50b909016 Reviewed-on: http://codereview.qt.nokia.com/3491 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: hjk <qthjk@ovi.com> --- src/plugins/projectexplorer/applicationlauncher.cpp | 3 +++ src/plugins/projectexplorer/applicationlauncher.h | 1 + .../projectexplorer/localapplicationruncontrol.cpp | 8 ++++++++ src/plugins/projectexplorer/localapplicationruncontrol.h | 1 + 4 files changed, 13 insertions(+) diff --git a/src/plugins/projectexplorer/applicationlauncher.cpp b/src/plugins/projectexplorer/applicationlauncher.cpp index c9db836642d..f19fe0d651a 100644 --- a/src/plugins/projectexplorer/applicationlauncher.cpp +++ b/src/plugins/projectexplorer/applicationlauncher.cpp @@ -111,6 +111,8 @@ ApplicationLauncher::ApplicationLauncher(QObject *parent) #ifdef Q_OS_UNIX d->m_consoleProcess.setSettings(Core::ICore::instance()->settings()); #endif + connect(&d->m_consoleProcess, SIGNAL(processStarted()), + this, SIGNAL(processStarted())); connect(&d->m_consoleProcess, SIGNAL(processError(QString)), this, SLOT(consoleProcessError(QString))); connect(&d->m_consoleProcess, SIGNAL(processStopped()), @@ -273,6 +275,7 @@ void ApplicationLauncher::processDone(int exitCode, QProcess::ExitStatus) void ApplicationLauncher::bringToForeground() { emit bringToForegroundRequested(applicationPID()); + emit processStarted(); } QString ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput() diff --git a/src/plugins/projectexplorer/applicationlauncher.h b/src/plugins/projectexplorer/applicationlauncher.h index 257401c63f3..cc36962b005 100644 --- a/src/plugins/projectexplorer/applicationlauncher.h +++ b/src/plugins/projectexplorer/applicationlauncher.h @@ -73,6 +73,7 @@ public: signals: void appendMessage(const QString &message, Utils::OutputFormat format); + void processStarted(); void processExited(int exitCode); void bringToForegroundRequested(qint64 pid); diff --git a/src/plugins/projectexplorer/localapplicationruncontrol.cpp b/src/plugins/projectexplorer/localapplicationruncontrol.cpp index 2260c6e2b14..456069bf1cd 100644 --- a/src/plugins/projectexplorer/localapplicationruncontrol.cpp +++ b/src/plugins/projectexplorer/localapplicationruncontrol.cpp @@ -92,6 +92,8 @@ LocalApplicationRunControl::LocalApplicationRunControl(LocalApplicationRunConfig connect(&m_applicationLauncher, SIGNAL(appendMessage(QString,Utils::OutputFormat)), 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(bringToForegroundRequested(qint64)), @@ -138,6 +140,12 @@ void LocalApplicationRunControl::slotAppendMessage(const QString &err, appendMessage(err, format); } +void LocalApplicationRunControl::processStarted() +{ + // Console processes only know their pid after being started + setApplicationProcessHandle(ProcessHandle(m_applicationLauncher.applicationPID())); +} + void LocalApplicationRunControl::processExited(int exitCode) { setApplicationProcessHandle(ProcessHandle()); diff --git a/src/plugins/projectexplorer/localapplicationruncontrol.h b/src/plugins/projectexplorer/localapplicationruncontrol.h index e8a9f05ed73..d0c793f232b 100644 --- a/src/plugins/projectexplorer/localapplicationruncontrol.h +++ b/src/plugins/projectexplorer/localapplicationruncontrol.h @@ -64,6 +64,7 @@ public: virtual bool isRunning() const; virtual QIcon icon() const; private slots: + void processStarted(); void processExited(int exitCode); void slotAppendMessage(const QString &err, Utils::OutputFormat isError); private: -- GitLab