forked from qt-creator/qt-creator
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:
@@ -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<void(QTimer::*)()>(&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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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<void (QProcess::*)(int,QProcess::ExitStatus)>(&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();
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user