From b7412814ab2389bfb1d5c8e6771310cbc6c6553e Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 6 Mar 2017 15:04:25 +0100 Subject: [PATCH] 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 --- src/plugins/debugger/qml/qmlengine.cpp | 15 +++++++++------ src/plugins/debugger/qml/qmlengine.h | 1 + src/plugins/nim/project/nimruncontrol.cpp | 3 +-- .../projectexplorer/applicationlauncher.cpp | 14 ++++---------- src/plugins/projectexplorer/applicationlauncher.h | 2 +- .../localapplicationruncontrol.cpp | 3 +-- src/plugins/pythoneditor/pythoneditorplugin.cpp | 3 +-- 7 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index 17b3e7ff707..06627e4da66 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -261,7 +261,7 @@ QmlEngine::QmlEngine(const DebuggerRunParameters &startParameters, DebuggerEngin connect(&d->applicationLauncher, &ApplicationLauncher::appendMessage, this, &QmlEngine::appendMessage); connect(&d->applicationLauncher, &ApplicationLauncher::processStarted, - &d->noDebugOutputTimer, static_cast(&QTimer::start)); + this, &QmlEngine::handleLauncherStarted); d->outputParser.setNoOutputText(ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput()); connect(&d->outputParser, &QmlOutputParser::waitingForConnectionOnPort, @@ -343,6 +343,14 @@ void QmlEngine::setupInferior() 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 */) { showMessage(msg, AppOutput); // FIXME: Redirect to RunControl @@ -646,11 +654,6 @@ void QmlEngine::setupEngine() // we need to get the port first notifyEngineRequestRemoteSetup(); } 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(); } } diff --git a/src/plugins/debugger/qml/qmlengine.h b/src/plugins/debugger/qml/qmlengine.h index 1f6b9c9bbe6..2c3b50a5d66 100644 --- a/src/plugins/debugger/qml/qmlengine.h +++ b/src/plugins/debugger/qml/qmlengine.h @@ -62,6 +62,7 @@ private: void tryToConnect(Utils::Port port = Utils::Port()); void beginConnection(Utils::Port port = Utils::Port()); + void handleLauncherStarted(); void connectionEstablished(); void connectionStartupFailed(); void appStartupFailed(const QString &errorMessage); diff --git a/src/plugins/nim/project/nimruncontrol.cpp b/src/plugins/nim/project/nimruncontrol.cpp index b0c4da00226..64a98ce99f5 100644 --- a/src/plugins/nim/project/nimruncontrol.cpp +++ b/src/plugins/nim/project/nimruncontrol.cpp @@ -47,8 +47,6 @@ NimRunControl::NimRunControl(NimRunConfiguration *rc, Core::Id mode) this, &NimRunControl::processStarted); connect(&m_applicationLauncher, &ApplicationLauncher::processExited, this, &NimRunControl::processExited); - connect(&m_applicationLauncher, &ApplicationLauncher::bringToForegroundRequested, - this, &RunControl::bringApplicationToForeground); } void NimRunControl::start() @@ -56,6 +54,7 @@ void NimRunControl::start() reportApplicationStart(); m_applicationLauncher.start(m_runnable); setApplicationProcessHandle(ProcessHandle(m_applicationLauncher.applicationPID())); + bringApplicationToForeground(); } ProjectExplorer::RunControl::StopResult NimRunControl::stop() diff --git a/src/plugins/projectexplorer/applicationlauncher.cpp b/src/plugins/projectexplorer/applicationlauncher.cpp index d8813999e4f..add5d0fd9f5 100644 --- a/src/plugins/projectexplorer/applicationlauncher.cpp +++ b/src/plugins/projectexplorer/applicationlauncher.cpp @@ -68,7 +68,7 @@ class ApplicationLauncherPrivate : public QObject public: explicit ApplicationLauncherPrivate(ApplicationLauncher *parent); - void handleLocalProcessStarted(); + void handleProcessStarted(); void localGuiProcessError(); void localConsoleProcessError(const QString &error); void readLocalStandardOutput(); @@ -117,14 +117,14 @@ ApplicationLauncherPrivate::ApplicationLauncherPrivate(ApplicationLauncher *pare connect(&m_guiProcess, static_cast(&QProcess::finished), this, &ApplicationLauncherPrivate::localProcessDone); connect(&m_guiProcess, &QProcess::started, - this, &ApplicationLauncherPrivate::bringToForeground); + this, &ApplicationLauncherPrivate::handleProcessStarted); connect(&m_guiProcess, &QProcess::errorOccurred, q, &ApplicationLauncher::error); m_consoleProcess.setSettings(Core::ICore::settings()); connect(&m_consoleProcess, &ConsoleProcess::processStarted, - this, &ApplicationLauncherPrivate::handleLocalProcessStarted); + this, &ApplicationLauncherPrivate::handleProcessStarted); connect(&m_consoleProcess, &ConsoleProcess::processError, this, &ApplicationLauncherPrivate::localConsoleProcessError); 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() { return tr("Cannot retrieve debugging output.") + QLatin1Char('\n'); } -void ApplicationLauncherPrivate::handleLocalProcessStarted() +void ApplicationLauncherPrivate::handleProcessStarted() { m_listeningPid = applicationPID(); emit q->processStarted(); diff --git a/src/plugins/projectexplorer/applicationlauncher.h b/src/plugins/projectexplorer/applicationlauncher.h index 7d3762c339d..ccf967ba929 100644 --- a/src/plugins/projectexplorer/applicationlauncher.h +++ b/src/plugins/projectexplorer/applicationlauncher.h @@ -60,6 +60,7 @@ public: QString errorString() const; QProcess::ProcessError processError() const; + void bringToForeground(); static QString msgWinCannotRetrieveDebuggingOutput(); @@ -67,7 +68,6 @@ signals: void appendMessage(const QString &message, Utils::OutputFormat format); void processStarted(); void processExited(int exitCode, QProcess::ExitStatus); - void bringToForegroundRequested(); void error(QProcess::ProcessError error); private: diff --git a/src/plugins/projectexplorer/localapplicationruncontrol.cpp b/src/plugins/projectexplorer/localapplicationruncontrol.cpp index 44826940ea5..f32e6c251eb 100644 --- a/src/plugins/projectexplorer/localapplicationruncontrol.cpp +++ b/src/plugins/projectexplorer/localapplicationruncontrol.cpp @@ -69,8 +69,6 @@ LocalApplicationRunControl::LocalApplicationRunControl(RunConfiguration *rc, Cor this, &LocalApplicationRunControl::processStarted); connect(&m_applicationLauncher, &ApplicationLauncher::processExited, this, &LocalApplicationRunControl::processExited); - connect(&m_applicationLauncher, &ApplicationLauncher::bringToForegroundRequested, - this, &RunControl::bringApplicationToForeground); } void LocalApplicationRunControl::start() @@ -104,6 +102,7 @@ void LocalApplicationRunControl::processStarted() { // Console processes only know their pid after being started setApplicationProcessHandle(ProcessHandle(m_applicationLauncher.applicationPID())); + bringApplicationToForeground(); } void LocalApplicationRunControl::processExited(int exitCode, QProcess::ExitStatus status) diff --git a/src/plugins/pythoneditor/pythoneditorplugin.cpp b/src/plugins/pythoneditor/pythoneditorplugin.cpp index f3f4ae18585..328cd59c925 100644 --- a/src/plugins/pythoneditor/pythoneditorplugin.cpp +++ b/src/plugins/pythoneditor/pythoneditorplugin.cpp @@ -770,8 +770,6 @@ PythonRunControl::PythonRunControl(PythonRunConfiguration *rc, Core::Id mode) this, &PythonRunControl::processStarted); connect(&m_applicationLauncher, &ApplicationLauncher::processExited, this, &PythonRunControl::processExited); - connect(&m_applicationLauncher, &ApplicationLauncher::bringToForegroundRequested, - this, &RunControl::bringApplicationToForeground); } void PythonRunControl::start() @@ -815,6 +813,7 @@ void PythonRunControl::processStarted() { // Console processes only know their pid after being started setApplicationProcessHandle(ProcessHandle(m_applicationLauncher.applicationPID())); + bringApplicationToForeground(); } void PythonRunControl::processExited(int exitCode, QProcess::ExitStatus status)