ProjectExplorer: Switch responsibilities for raising applications

Instead of letting the launcher decide to raise something when
started (and only then) leave it to the RunControl to trigger
(and for now also to implement) as response to the application
launcher start (or possibly now, in other circumstances).

Change-Id: I0ac8f1e633981f7bf316c88e83c208765886d9a1
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
hjk
2017-03-06 15:04:25 +01:00
parent 9a126e37f9
commit b7412814ab
7 changed files with 18 additions and 23 deletions

View File

@@ -261,7 +261,7 @@ QmlEngine::QmlEngine(const DebuggerRunParameters &startParameters, DebuggerEngin
connect(&d->applicationLauncher, &ApplicationLauncher::appendMessage, connect(&d->applicationLauncher, &ApplicationLauncher::appendMessage,
this, &QmlEngine::appendMessage); this, &QmlEngine::appendMessage);
connect(&d->applicationLauncher, &ApplicationLauncher::processStarted, connect(&d->applicationLauncher, &ApplicationLauncher::processStarted,
&d->noDebugOutputTimer, static_cast<void(QTimer::*)()>(&QTimer::start)); this, &QmlEngine::handleLauncherStarted);
d->outputParser.setNoOutputText(ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput()); d->outputParser.setNoOutputText(ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput());
connect(&d->outputParser, &QmlOutputParser::waitingForConnectionOnPort, connect(&d->outputParser, &QmlOutputParser::waitingForConnectionOnPort,
@@ -343,6 +343,14 @@ void QmlEngine::setupInferior()
beginConnection(); beginConnection();
} }
void QmlEngine::handleLauncherStarted()
{
// FIXME: The QmlEngine never calls notifyInferiorPid() triggering the
// raising, so do it here manually for now.
runControl()->bringApplicationToForeground();
d->noDebugOutputTimer.start();
}
void QmlEngine::appendMessage(const QString &msg, Utils::OutputFormat /* format */) void QmlEngine::appendMessage(const QString &msg, Utils::OutputFormat /* format */)
{ {
showMessage(msg, AppOutput); // FIXME: Redirect to RunControl showMessage(msg, AppOutput); // FIXME: Redirect to RunControl
@@ -646,11 +654,6 @@ void QmlEngine::setupEngine()
// we need to get the port first // we need to get the port first
notifyEngineRequestRemoteSetup(); notifyEngineRequestRemoteSetup();
} else { } else {
// We can't do this in the constructore because runControl() isn't yet defined
connect(&d->applicationLauncher, &ApplicationLauncher::bringToForegroundRequested,
runControl(), &RunControl::bringApplicationToForeground,
Qt::UniqueConnection);
notifyEngineSetupOk(); notifyEngineSetupOk();
} }
} }

View File

@@ -62,6 +62,7 @@ private:
void tryToConnect(Utils::Port port = Utils::Port()); void tryToConnect(Utils::Port port = Utils::Port());
void beginConnection(Utils::Port port = Utils::Port()); void beginConnection(Utils::Port port = Utils::Port());
void handleLauncherStarted();
void connectionEstablished(); void connectionEstablished();
void connectionStartupFailed(); void connectionStartupFailed();
void appStartupFailed(const QString &errorMessage); void appStartupFailed(const QString &errorMessage);

View File

@@ -47,8 +47,6 @@ NimRunControl::NimRunControl(NimRunConfiguration *rc, Core::Id mode)
this, &NimRunControl::processStarted); this, &NimRunControl::processStarted);
connect(&m_applicationLauncher, &ApplicationLauncher::processExited, connect(&m_applicationLauncher, &ApplicationLauncher::processExited,
this, &NimRunControl::processExited); this, &NimRunControl::processExited);
connect(&m_applicationLauncher, &ApplicationLauncher::bringToForegroundRequested,
this, &RunControl::bringApplicationToForeground);
} }
void NimRunControl::start() void NimRunControl::start()
@@ -56,6 +54,7 @@ void NimRunControl::start()
reportApplicationStart(); reportApplicationStart();
m_applicationLauncher.start(m_runnable); m_applicationLauncher.start(m_runnable);
setApplicationProcessHandle(ProcessHandle(m_applicationLauncher.applicationPID())); setApplicationProcessHandle(ProcessHandle(m_applicationLauncher.applicationPID()));
bringApplicationToForeground();
} }
ProjectExplorer::RunControl::StopResult NimRunControl::stop() ProjectExplorer::RunControl::StopResult NimRunControl::stop()

View File

@@ -68,7 +68,7 @@ class ApplicationLauncherPrivate : public QObject
public: public:
explicit ApplicationLauncherPrivate(ApplicationLauncher *parent); explicit ApplicationLauncherPrivate(ApplicationLauncher *parent);
void handleLocalProcessStarted(); void handleProcessStarted();
void localGuiProcessError(); void localGuiProcessError();
void localConsoleProcessError(const QString &error); void localConsoleProcessError(const QString &error);
void readLocalStandardOutput(); void readLocalStandardOutput();
@@ -117,14 +117,14 @@ ApplicationLauncherPrivate::ApplicationLauncherPrivate(ApplicationLauncher *pare
connect(&m_guiProcess, static_cast<void (QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), connect(&m_guiProcess, static_cast<void (QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished),
this, &ApplicationLauncherPrivate::localProcessDone); this, &ApplicationLauncherPrivate::localProcessDone);
connect(&m_guiProcess, &QProcess::started, connect(&m_guiProcess, &QProcess::started,
this, &ApplicationLauncherPrivate::bringToForeground); this, &ApplicationLauncherPrivate::handleProcessStarted);
connect(&m_guiProcess, &QProcess::errorOccurred, connect(&m_guiProcess, &QProcess::errorOccurred,
q, &ApplicationLauncher::error); q, &ApplicationLauncher::error);
m_consoleProcess.setSettings(Core::ICore::settings()); m_consoleProcess.setSettings(Core::ICore::settings());
connect(&m_consoleProcess, &ConsoleProcess::processStarted, connect(&m_consoleProcess, &ConsoleProcess::processStarted,
this, &ApplicationLauncherPrivate::handleLocalProcessStarted); this, &ApplicationLauncherPrivate::handleProcessStarted);
connect(&m_consoleProcess, &ConsoleProcess::processError, connect(&m_consoleProcess, &ConsoleProcess::processError,
this, &ApplicationLauncherPrivate::localConsoleProcessError); this, &ApplicationLauncherPrivate::localConsoleProcessError);
connect(&m_consoleProcess, &ConsoleProcess::processStopped, connect(&m_consoleProcess, &ConsoleProcess::processStopped,
@@ -319,18 +319,12 @@ void ApplicationLauncherPrivate::localProcessDone(int exitCode, QProcess::ExitSt
}); });
} }
void ApplicationLauncherPrivate::bringToForeground()
{
handleLocalProcessStarted();
emit q->bringToForegroundRequested();
}
QString ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput() QString ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput()
{ {
return tr("Cannot retrieve debugging output.") + QLatin1Char('\n'); return tr("Cannot retrieve debugging output.") + QLatin1Char('\n');
} }
void ApplicationLauncherPrivate::handleLocalProcessStarted() void ApplicationLauncherPrivate::handleProcessStarted()
{ {
m_listeningPid = applicationPID(); m_listeningPid = applicationPID();
emit q->processStarted(); emit q->processStarted();

View File

@@ -60,6 +60,7 @@ public:
QString errorString() const; QString errorString() const;
QProcess::ProcessError processError() const; QProcess::ProcessError processError() const;
void bringToForeground();
static QString msgWinCannotRetrieveDebuggingOutput(); static QString msgWinCannotRetrieveDebuggingOutput();
@@ -67,7 +68,6 @@ signals:
void appendMessage(const QString &message, Utils::OutputFormat format); void appendMessage(const QString &message, Utils::OutputFormat format);
void processStarted(); void processStarted();
void processExited(int exitCode, QProcess::ExitStatus); void processExited(int exitCode, QProcess::ExitStatus);
void bringToForegroundRequested();
void error(QProcess::ProcessError error); void error(QProcess::ProcessError error);
private: private:

View File

@@ -69,8 +69,6 @@ LocalApplicationRunControl::LocalApplicationRunControl(RunConfiguration *rc, Cor
this, &LocalApplicationRunControl::processStarted); this, &LocalApplicationRunControl::processStarted);
connect(&m_applicationLauncher, &ApplicationLauncher::processExited, connect(&m_applicationLauncher, &ApplicationLauncher::processExited,
this, &LocalApplicationRunControl::processExited); this, &LocalApplicationRunControl::processExited);
connect(&m_applicationLauncher, &ApplicationLauncher::bringToForegroundRequested,
this, &RunControl::bringApplicationToForeground);
} }
void LocalApplicationRunControl::start() void LocalApplicationRunControl::start()
@@ -104,6 +102,7 @@ void LocalApplicationRunControl::processStarted()
{ {
// Console processes only know their pid after being started // Console processes only know their pid after being started
setApplicationProcessHandle(ProcessHandle(m_applicationLauncher.applicationPID())); setApplicationProcessHandle(ProcessHandle(m_applicationLauncher.applicationPID()));
bringApplicationToForeground();
} }
void LocalApplicationRunControl::processExited(int exitCode, QProcess::ExitStatus status) void LocalApplicationRunControl::processExited(int exitCode, QProcess::ExitStatus status)

View File

@@ -770,8 +770,6 @@ PythonRunControl::PythonRunControl(PythonRunConfiguration *rc, Core::Id mode)
this, &PythonRunControl::processStarted); this, &PythonRunControl::processStarted);
connect(&m_applicationLauncher, &ApplicationLauncher::processExited, connect(&m_applicationLauncher, &ApplicationLauncher::processExited,
this, &PythonRunControl::processExited); this, &PythonRunControl::processExited);
connect(&m_applicationLauncher, &ApplicationLauncher::bringToForegroundRequested,
this, &RunControl::bringApplicationToForeground);
} }
void PythonRunControl::start() void PythonRunControl::start()
@@ -815,6 +813,7 @@ void PythonRunControl::processStarted()
{ {
// Console processes only know their pid after being started // Console processes only know their pid after being started
setApplicationProcessHandle(ProcessHandle(m_applicationLauncher.applicationPID())); setApplicationProcessHandle(ProcessHandle(m_applicationLauncher.applicationPID()));
bringApplicationToForeground();
} }
void PythonRunControl::processExited(int exitCode, QProcess::ExitStatus status) void PythonRunControl::processExited(int exitCode, QProcess::ExitStatus status)