Commit d049a5be authored by hjk's avatar hjk

Debugger: Base magic Qml connection discover on base run control signal

Less debugger specific code and less convoluted paths in debugger
message handling.

Change-Id: Ib298889c386d65f17acbdfc585188097bb20ed74
Reviewed-by: Christian Stenger's avatarChristian Stenger <christian.stenger@qt.io>
parent 5b3ed3f9
......@@ -477,6 +477,8 @@ private:
class DebuggerRunTool : public ProjectExplorer::ToolRunner
{
Q_OBJECT
public:
DebuggerRunTool(ProjectExplorer::RunControl *runControl,
const DebuggerRunParameters &rp,
......
......@@ -582,7 +582,8 @@ void DebuggerRunTool::showMessage(const QString &msg, int channel, int timeout)
DebuggerEngine *engine(const DebuggerRunControl *runControl)
{
return static_cast<DebuggerRunTool *>(runControl->toolRunner())->engine();
QTC_ASSERT(runControl, return nullptr);
return qobject_cast<DebuggerRunTool *>(runControl->toolRunner())->engine();
}
......
......@@ -743,15 +743,6 @@ void QmlCppEngine::notifyEngineRemoteSetupFinished(const RemoteSetupResult &resu
qmlEngine()->notifyEngineRemoteSetupFinished(result);
}
void QmlCppEngine::showMessage(const QString &msg, int channel, int timeout) const
{
if (channel == AppOutput || channel == AppError || channel == AppStuff) {
// message is from CppEngine, allow qml engine to process
m_qmlEngine->filterApplicationMessage(msg, channel);
}
DebuggerEngine::showMessage(msg, channel, timeout);
}
void QmlCppEngine::resetLocation()
{
if (m_qmlEngine)
......
......@@ -82,11 +82,7 @@ public:
DebuggerEngine *qmlEngine() const;
void notifyEngineRemoteSetupFinished(const RemoteSetupResult &result) override;
void showMessage(const QString &msg, int channel = LogDebug,
int timeout = -1) const override;
void resetLocation() override;
void notifyInferiorIll() override;
protected:
......
......@@ -135,7 +135,7 @@ struct LookupData
typedef QHash<int, LookupData> LookupItems; // id -> (iname, exp)
class QmlEnginePrivate : QmlDebugClient
class QmlEnginePrivate : public QmlDebugClient
{
public:
QmlEnginePrivate(QmlEngine *engine_, QmlDebugConnection *connection_)
......@@ -188,6 +188,17 @@ public:
void checkForFinishedUpdate();
ConsoleItem *constructLogItemTree(const QmlV8ObjectData &objectData);
void filterApplicationMessage(ProjectExplorer::RunControl *runControl,
const QString &msg, Utils::OutputFormat format)
{
if (runControl != engine->runControl())
return;
if (format == StdErrFormatSameLine
|| format == StdOutFormatSameLine
|| format == DebugFormat)
outputParser.processOutput(msg);
}
public:
QHash<int, QmlV8ObjectData> refVals; // The mapping of target object handles to retrieved values.
int sequence = -1;
......@@ -225,6 +236,8 @@ public:
QmlDebug::QDebugMessageClient *msgClient = 0;
QHash<int, QmlCallback> callbackForToken;
QMetaObject::Connection startupMessageFilterConnection;
private:
ConsoleItem *constructLogItemTree(const QmlV8ObjectData &objectData, QList<int> &seenHandles);
void constructChildLogItems(ConsoleItem *item, const QmlV8ObjectData &objectData,
......@@ -322,6 +335,10 @@ QmlEngine::QmlEngine(const DebuggerRunParameters &startParameters, DebuggerEngin
connect(d->msgClient, &QDebugMessageClient::message,
this, &appendDebugOutput);
d->startupMessageFilterConnection = connect(
runControl(), &RunControl::appendMessageRequested,
d, &QmlEnginePrivate::filterApplicationMessage);
}
QmlEngine::~QmlEngine()
......@@ -493,18 +510,6 @@ void QmlEngine::errorMessageBoxFinished(int result)
}
}
void QmlEngine::filterApplicationMessage(const QString &output, int /*channel*/) const
{
d->outputParser.processOutput(output);
}
void QmlEngine::showMessage(const QString &msg, int channel, int timeout) const
{
if (channel == AppOutput || channel == AppError)
filterApplicationMessage(msg, channel);
DebuggerEngine::showMessage(msg, channel, timeout);
}
void QmlEngine::gotoLocation(const Location &location)
{
const QString fileName = location.fileName();
......@@ -582,6 +587,7 @@ void QmlEngine::stopApplicationLauncher()
void QmlEngine::notifyEngineRemoteSetupFinished(const RemoteSetupResult &result)
{
QObject::disconnect(d->startupMessageFilterConnection);
DebuggerEngine::notifyEngineRemoteSetupFinished(result);
if (result.success) {
......
......@@ -47,8 +47,6 @@ public:
DebuggerEngine *masterEngine = nullptr);
~QmlEngine() override;
void filterApplicationMessage(const QString &msg, int channel) const;
void logServiceStateChange(const QString &service, float version,
QmlDebug::QmlDebugClient::State newState);
void logServiceActivity(const QString &service, const QString &logMessage);
......@@ -71,8 +69,6 @@ private:
void notifyEngineRemoteServerRunning(const QString &, int pid) override;
void notifyEngineRemoteSetupFinished(const RemoteSetupResult &result) override;
void showMessage(const QString &msg, int channel = LogDebug,
int timeout = -1) const override;
void gotoLocation(const Internal::Location &location) override;
void insertBreakpoint(Breakpoint bp) override;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment