forked from qt-creator/qt-creator
ProjectExplorer: Make RunControl::bringApplicationToForeground virtual
No practical change as the only case that is used so far are local setups on Mac. It's a conceptual change, though, giving concrete RunControl implementation the chance to act "sensibly", e.g. by raising a locally running simulator control in case of remote setups or such. Change-Id: I5679428934fe08b8c9756f3906ee3d9073278822 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -311,7 +311,7 @@ public:
|
||||
void raiseApplication()
|
||||
{
|
||||
QTC_ASSERT(runControl(), return);
|
||||
runControl()->bringApplicationToForeground(m_inferiorPid.pid());
|
||||
runControl()->bringApplicationToForeground();
|
||||
}
|
||||
|
||||
void scheduleResetLocation()
|
||||
|
@@ -281,8 +281,8 @@ void ApplicationLauncher::processDone(int exitCode, QProcess::ExitStatus status)
|
||||
|
||||
void ApplicationLauncher::bringToForeground()
|
||||
{
|
||||
emit bringToForegroundRequested(applicationPID());
|
||||
handleProcessStarted();
|
||||
emit bringToForegroundRequested();
|
||||
}
|
||||
|
||||
QString ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput()
|
||||
|
@@ -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:
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user