Commit 70f3f5d0 authored by Olivier Goffart's avatar Olivier Goffart
Browse files

QML JS Debugger: Asynchronous call to watchHandler()->endCycle()

All the expended item need to be retreived before we can call endCycle
parent 3114c47c
......@@ -176,7 +176,7 @@ public:
///////////////////////////////////////////////////////////////////////
QmlEngine::QmlEngine(const DebuggerStartParameters &startParameters)
: DebuggerEngine(startParameters)
: DebuggerEngine(startParameters), m_ping(0)
{
/*
m_conn = 0;
......@@ -339,7 +339,6 @@ void QmlEngine::setupConnection()
void QmlEngine::continueInferior()
{
QTC_ASSERT(state() == InferiorStopOk, qDebug() << state());
SDEBUG("QmlEngine::continueInferior()");
QByteArray reply;
QDataStream rs(&reply, QIODevice::WriteOnly);
rs << QByteArray("CONTINUE");
......@@ -359,7 +358,6 @@ void QmlEngine::interruptInferior()
void QmlEngine::executeStep()
{
SDEBUG("QmlEngine::executeStep()");
QByteArray reply;
QDataStream rs(&reply, QIODevice::WriteOnly);
rs << QByteArray("STEPINTO");
......@@ -370,7 +368,6 @@ void QmlEngine::executeStep()
void QmlEngine::executeStepI()
{
SDEBUG("QmlEngine::executeStepI()");
QByteArray reply;
QDataStream rs(&reply, QIODevice::WriteOnly);
rs << QByteArray("STEPINTO");
......@@ -381,7 +378,6 @@ void QmlEngine::executeStepI()
void QmlEngine::executeStepOut()
{
SDEBUG("QmlEngine::executeStepOut()");
QByteArray reply;
QDataStream rs(&reply, QIODevice::WriteOnly);
rs << QByteArray("STEPOUT");
......@@ -398,7 +394,6 @@ void QmlEngine::executeNext()
sendMessage(reply);
notifyInferiorRunRequested();
notifyInferiorRunOk();
SDEBUG("QmlEngine::nextExec()");
}
void QmlEngine::executeNextI()
......@@ -571,6 +566,17 @@ void QmlEngine::expandObject(const QByteArray& iname, quint64 objectId)
sendMessage(reply);
}
void QmlEngine::sendPing()
{
m_ping++;
QByteArray reply;
QDataStream rs(&reply, QIODevice::WriteOnly);
rs << QByteArray("PING");
rs << m_ping;
sendMessage(reply);
}
DebuggerEngine *createQmlEngine(const DebuggerStartParameters &sp)
{
......@@ -622,23 +628,31 @@ void QmlEngine::messageReceived(const QByteArray &message)
stackHandler()->setFrames(stackFrames);
watchHandler()->beginCycle();
bool needPing = false;
foreach (WatchData data, watches) {
data.iname = watchHandler()->watcherName(data.exp);
watchHandler()->insertData(data);
if (watchHandler()->expandedINames().contains(data.iname))
if (watchHandler()->expandedINames().contains(data.iname)) {
needPing = true;
expandObject(data.iname, data.objectId);
}
}
foreach (WatchData data, locals) {
data.iname = "local." + data.exp;
watchHandler()->insertData(data);
if (watchHandler()->expandedINames().contains(data.iname))
if (watchHandler()->expandedINames().contains(data.iname)) {
needPing = true;
expandObject(data.iname, data.objectId);
}
}
if (needPing)
sendPing();
else
watchHandler()->endCycle();
} else if (command == "RESULT") {
......@@ -652,24 +666,41 @@ void QmlEngine::messageReceived(const QByteArray &message)
QList<WatchData> result;
QByteArray iname;
stream >> iname >> result;
bool needPing = false;
foreach (WatchData data, result) {
data.iname = iname + '.' + data.exp;
watchHandler()->insertData(data);
if (watchHandler()->expandedINames().contains(data.iname))
if (watchHandler()->expandedINames().contains(data.iname)) {
needPing = true;
expandObject(data.iname, data.objectId);
}
}
if (needPing)
sendPing();
} else if (command == "LOCALS") {
QList<WatchData> locals;
int frameId;
stream >> frameId >> locals;
watchHandler()->beginCycle();
bool needPing = false;
foreach (WatchData data, locals) {
data.iname = "local." + data.exp;
watchHandler()->insertData(data);
if (watchHandler()->expandedINames().contains(data.iname))
if (watchHandler()->expandedINames().contains(data.iname)) {
needPing = true;
expandObject(data.iname, data.objectId);
}
}
if (needPing)
sendPing();
else
watchHandler()->endCycle();
} else if (command == "PONG") {
int ping;
stream >> ping;
if (ping == m_ping)
watchHandler()->endCycle();
} else {
qDebug() << Q_FUNC_INFO << "Unknown command: " << command;
......
......@@ -70,6 +70,7 @@ class DEBUGGER_EXPORT QmlEngine : public DebuggerEngine
{
Q_OBJECT
int m_ping;
public:
explicit QmlEngine(const DebuggerStartParameters &startParameters);
~QmlEngine();
......@@ -117,7 +118,6 @@ private:
void reloadFullStack() {}
bool supportsThreads() const { return true; }
void maybeBreakNow(bool byFunction);
void updateWatchData(const WatchData &data);
unsigned int debuggerCapabilities() const;
......@@ -128,6 +128,7 @@ signals:
private:
void expandObject(const QByteArray &iname, quint64 objectId);
void sendPing();
#if 0
void createDockWidgets();
......
......@@ -408,6 +408,13 @@ void JSDebuggerAgent::messageReceived(const QByteArray& message)
}
state = oldState;
//TODO: feedback
} else if (command == "PING") {
int ping;
ds >> ping;
QByteArray reply;
QDataStream rs(&reply, QIODevice::WriteOnly);
rs << QByteArray("PONG") << ping;
sendMessage(reply);
} else {
qDebug() << Q_FUNC_INFO << "Unknown command" << command;
}
......
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