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>
This commit is contained in:
Daniel Teske
2011-08-24 13:00:57 +02:00
committed by hjk
parent 258727ab57
commit fbd9ae120f
4 changed files with 13 additions and 0 deletions

View File

@@ -111,6 +111,8 @@ ApplicationLauncher::ApplicationLauncher(QObject *parent)
#ifdef Q_OS_UNIX #ifdef Q_OS_UNIX
d->m_consoleProcess.setSettings(Core::ICore::instance()->settings()); d->m_consoleProcess.setSettings(Core::ICore::instance()->settings());
#endif #endif
connect(&d->m_consoleProcess, SIGNAL(processStarted()),
this, SIGNAL(processStarted()));
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()), connect(&d->m_consoleProcess, SIGNAL(processStopped()),
@@ -273,6 +275,7 @@ void ApplicationLauncher::processDone(int exitCode, QProcess::ExitStatus)
void ApplicationLauncher::bringToForeground() void ApplicationLauncher::bringToForeground()
{ {
emit bringToForegroundRequested(applicationPID()); emit bringToForegroundRequested(applicationPID());
emit processStarted();
} }
QString ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput() QString ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput()

View File

@@ -73,6 +73,7 @@ public:
signals: signals:
void appendMessage(const QString &message, Utils::OutputFormat format); void appendMessage(const QString &message, Utils::OutputFormat format);
void processStarted();
void processExited(int exitCode); void processExited(int exitCode);
void bringToForegroundRequested(qint64 pid); void bringToForegroundRequested(qint64 pid);

View File

@@ -92,6 +92,8 @@ LocalApplicationRunControl::LocalApplicationRunControl(LocalApplicationRunConfig
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(processStarted()),
this, SLOT(processStarted()));
connect(&m_applicationLauncher, SIGNAL(processExited(int)), connect(&m_applicationLauncher, SIGNAL(processExited(int)),
this, SLOT(processExited(int))); this, SLOT(processExited(int)));
connect(&m_applicationLauncher, SIGNAL(bringToForegroundRequested(qint64)), connect(&m_applicationLauncher, SIGNAL(bringToForegroundRequested(qint64)),
@@ -138,6 +140,12 @@ void LocalApplicationRunControl::slotAppendMessage(const QString &err,
appendMessage(err, format); 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) void LocalApplicationRunControl::processExited(int exitCode)
{ {
setApplicationProcessHandle(ProcessHandle()); setApplicationProcessHandle(ProcessHandle());

View File

@@ -64,6 +64,7 @@ public:
virtual bool isRunning() const; virtual bool isRunning() const;
virtual QIcon icon() const; virtual QIcon icon() const;
private slots: private slots:
void processStarted();
void processExited(int exitCode); void processExited(int exitCode);
void slotAppendMessage(const QString &err, Utils::OutputFormat isError); void slotAppendMessage(const QString &err, Utils::OutputFormat isError);
private: private: