Debugger: Use QtcProcess instead of ApplicationLauncher

... to start the QmlEngine

Change-Id: Id283a1f5d100cd65fe1f3b900114b86aca288e91
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2022-05-04 16:30:55 +02:00
parent 79301deea2
commit adeaa01d85
2 changed files with 34 additions and 37 deletions

View File

@@ -47,8 +47,6 @@
#include <coreplugin/helpmanager.h> #include <coreplugin/helpmanager.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <projectexplorer/applicationlauncher.h>
#include <qmljseditor/qmljseditorconstants.h> #include <qmljseditor/qmljseditorconstants.h>
#include <qmljs/qmljsmodelmanagerinterface.h> #include <qmljs/qmljsmodelmanagerinterface.h>
#include <qmldebug/qmldebugconnection.h> #include <qmldebug/qmldebugconnection.h>
@@ -58,10 +56,12 @@
#include <texteditor/texteditor.h> #include <texteditor/texteditor.h>
#include <app/app_version.h> #include <app/app_version.h>
#include <utils/treemodel.h>
#include <utils/basetreeview.h> #include <utils/basetreeview.h>
#include <utils/fileinprojectfinder.h> #include <utils/fileinprojectfinder.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
#include <utils/treemodel.h>
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
@@ -220,7 +220,7 @@ public:
QHash<QString, QTextDocument*> sourceDocuments; QHash<QString, QTextDocument*> sourceDocuments;
InteractiveInterpreter interpreter; InteractiveInterpreter interpreter;
ApplicationLauncher applicationLauncher; QtcProcess process;
QmlInspectorAgent inspectorAgent; QmlInspectorAgent inspectorAgent;
QList<quint32> queryIds; QList<quint32> queryIds;
@@ -269,12 +269,17 @@ QmlEngine::QmlEngine()
connect(stackHandler(), &StackHandler::currentIndexChanged, connect(stackHandler(), &StackHandler::currentIndexChanged,
this, &QmlEngine::updateCurrentContext); this, &QmlEngine::updateCurrentContext);
connect(&d->applicationLauncher, &ApplicationLauncher::finished, connect(&d->process, &QtcProcess::readyReadStandardOutput, this, [this] {
this, &QmlEngine::disconnected); // FIXME: Redirect to RunControl
connect(&d->applicationLauncher, &ApplicationLauncher::appendMessage, showMessage(QString::fromUtf8(d->process.readAllStandardOutput()), AppOutput);
this, &QmlEngine::appMessage); });
connect(&d->applicationLauncher, &ApplicationLauncher::started, connect(&d->process, &QtcProcess::readyReadStandardError, this, [this] {
this, &QmlEngine::handleLauncherStarted); // FIXME: Redirect to RunControl
showMessage(QString::fromUtf8(d->process.readAllStandardError()), AppOutput);
});
connect(&d->process, &QtcProcess::finished, this, &QmlEngine::disconnected);
connect(&d->process, &QtcProcess::started, this, &QmlEngine::handleLauncherStarted);
debuggerConsole()->populateFileFinder(); debuggerConsole()->populateFileFinder();
debuggerConsole()->setScriptEvaluator([this](const QString &expr) { debuggerConsole()->setScriptEvaluator([this](const QString &expr) {
@@ -329,11 +334,6 @@ void QmlEngine::handleLauncherStarted()
tryToConnect(); tryToConnect();
} }
void QmlEngine::appMessage(const QString &msg, Utils::OutputFormat /* format */)
{
showMessage(msg, AppOutput); // FIXME: Redirect to RunControl
}
void QmlEngine::connectionEstablished() void QmlEngine::connectionEstablished()
{ {
connect(inspectorView(), &WatchTreeView::currentIndexChanged, connect(inspectorView(), &WatchTreeView::currentIndexChanged,
@@ -502,25 +502,23 @@ void QmlEngine::closeConnection()
} }
} }
void QmlEngine::startApplicationLauncher() void QmlEngine::startProcess()
{ {
if (!d->applicationLauncher.isRunning()) { if (d->process.isRunning())
Runnable runnable = runParameters().inferior; return;
runnable.device.reset();
showMessage(tr("Starting %1").arg(runnable.command.toUserOutput()), d->process.setCommand(runParameters().inferior.command);
NormalMessageFormat); d->process.setWorkingDirectory(runParameters().inferior.workingDirectory);
d->applicationLauncher.setRunnable(runnable); d->process.setEnvironment(runParameters().inferior.environment);
d->applicationLauncher.start(); showMessage(tr("Starting %1").arg(d->process.commandLine().toUserOutput()),
} NormalMessageFormat);
d->process.start();
} }
void QmlEngine::stopApplicationLauncher() void QmlEngine::stopProcess()
{ {
if (d->applicationLauncher.isRunning()) { if (d->process.isRunning())
disconnect(&d->applicationLauncher, &ApplicationLauncher::finished, d->process.close();
this, &QmlEngine::disconnected);
d->applicationLauncher.stop();
}
} }
void QmlEngine::shutdownInferior() void QmlEngine::shutdownInferior()
@@ -534,7 +532,7 @@ void QmlEngine::shutdownInferior()
d->runCommand({DISCONNECT}); d->runCommand({DISCONNECT});
resetLocation(); resetLocation();
stopApplicationLauncher(); stopProcess();
closeConnection(); closeConnection();
notifyInferiorShutdownFinished(); notifyInferiorShutdownFinished();
@@ -547,7 +545,7 @@ void QmlEngine::shutdownEngine()
debuggerConsole()->setScriptEvaluator(ScriptEvaluator()); debuggerConsole()->setScriptEvaluator(ScriptEvaluator());
// double check (ill engine?): // double check (ill engine?):
stopApplicationLauncher(); stopProcess();
notifyEngineShutdownFinished(); notifyEngineShutdownFinished();
} }
@@ -571,7 +569,7 @@ void QmlEngine::setupEngine()
else if (runParameters().startMode == AttachToRemoteProcess) else if (runParameters().startMode == AttachToRemoteProcess)
beginConnection(); beginConnection();
else else
startApplicationLauncher(); startProcess();
} else { } else {
tryToConnect(); tryToConnect();
} }
@@ -959,7 +957,7 @@ void QmlEngine::quitDebugger()
{ {
d->automaticConnect = false; d->automaticConnect = false;
d->retryOnConnectFail = false; d->retryOnConnectFail = false;
stopApplicationLauncher(); stopProcess();
closeConnection(); closeConnection();
} }

View File

@@ -63,7 +63,6 @@ private:
void connectionEstablished(); void connectionEstablished();
void connectionStartupFailed(); void connectionStartupFailed();
void appStartupFailed(const QString &errorMessage); void appStartupFailed(const QString &errorMessage);
void appMessage(const QString &msg, Utils::OutputFormat);
void setState(DebuggerState state, bool forced) override; void setState(DebuggerState state, bool forced) override;
@@ -123,8 +122,8 @@ private:
Core::Context languageContext() const override; Core::Context languageContext() const override;
void closeConnection(); void closeConnection();
void startApplicationLauncher(); void startProcess();
void stopApplicationLauncher(); void stopProcess();
void connectionFailed(); void connectionFailed();