diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index bf15de1bcf2..54abc695138 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -311,7 +311,7 @@ public: void raiseApplication() { QTC_ASSERT(runControl(), return); - runControl()->bringApplicationToForeground(m_inferiorPid.pid()); + runControl()->bringApplicationToForeground(); } void scheduleResetLocation() diff --git a/src/plugins/projectexplorer/applicationlauncher.cpp b/src/plugins/projectexplorer/applicationlauncher.cpp index e1dfc40c560..e8d38de4c61 100644 --- a/src/plugins/projectexplorer/applicationlauncher.cpp +++ b/src/plugins/projectexplorer/applicationlauncher.cpp @@ -281,8 +281,8 @@ void ApplicationLauncher::processDone(int exitCode, QProcess::ExitStatus status) void ApplicationLauncher::bringToForeground() { - emit bringToForegroundRequested(applicationPID()); handleProcessStarted(); + emit bringToForegroundRequested(); } QString ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput() diff --git a/src/plugins/projectexplorer/applicationlauncher.h b/src/plugins/projectexplorer/applicationlauncher.h index e27729722b6..8e7827f191a 100644 --- a/src/plugins/projectexplorer/applicationlauncher.h +++ b/src/plugins/projectexplorer/applicationlauncher.h @@ -65,7 +65,7 @@ signals: void appendMessage(const QString &message, Utils::OutputFormat format); void processStarted(); void processExited(int exitCode, QProcess::ExitStatus); - void bringToForegroundRequested(qint64 pid); + void bringToForegroundRequested(); void error(QProcess::ProcessError error); private: diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 443491b1af3..71361c1ccee 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -538,9 +538,8 @@ public: bool isRunning = false; #ifdef Q_OS_OSX - //these two are used to bring apps in the foreground on Mac + // This is used to bring apps in the foreground on Mac int foregroundCount; - qint64 internalPid; #endif }; @@ -656,6 +655,13 @@ bool RunControl::canReUseOutputPane(const RunControl *other) const return d->runnable.canReUseOutputPane(other->d->runnable); } +/*! + A handle to the application process. + + This is typically a process id, but should be treated as + opaque handle to the process controled by this \c RunControl. +*/ + ProcessHandle RunControl::applicationProcessHandle() const { return d->applicationProcessHandle; @@ -729,14 +735,18 @@ bool RunControl::showPromptToStopDialog(const QString &title, return close; } -void RunControl::bringApplicationToForeground(qint64 pid) +/*! + Brings the application determined by this RunControl's \c applicationProcessHandle + to the foreground. + + The default implementation raises the application on Mac, and does + nothing elsewhere. +*/ +void RunControl::bringApplicationToForeground() { #ifdef Q_OS_OSX - d->internalPid = pid; d->foregroundCount = 0; bringApplicationToForegroundInternal(); -#else - Q_UNUSED(pid) #endif } @@ -758,14 +768,13 @@ void RunControl::bringApplicationToForegroundInternal() { #ifdef Q_OS_OSX ProcessSerialNumber psn; - GetProcessForPID(d->internalPid, &psn); + GetProcessForPID(d->applicationProcessHandle.pid(), &psn); if (SetFrontProcess(&psn) == procNotFound && d->foregroundCount < 15) { // somehow the mac/carbon api says // "-600 no eligible process with specified process id" // if we call SetFrontProcess too early ++d->foregroundCount; QTimer::singleShot(200, this, &RunControl::bringApplicationToForegroundInternal); - return; } #endif } diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index f50ff7c10b0..753b3bf494f 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -391,9 +391,7 @@ public: void setConnection(const Connection &connection); virtual void appendMessage(const QString &msg, Utils::OutputFormat format); - -public slots: - void bringApplicationToForeground(qint64 pid); + virtual void bringApplicationToForeground(); signals: void appendMessageRequested(ProjectExplorer::RunControl *runControl,