QML Debugger: Make sure to claim break points before CONNECT

Otherwise we have a race condition. The breakpoints may be hit before
they are set.

Change-Id: Iccdd64758b150acdfadc18cba88abdf841feb6c7
Fixes: QTCREATORBUG-21253
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Ulf Hermann
2018-10-09 10:59:46 +02:00
parent df08e1ee3d
commit 6a19eebfc2

View File

@@ -349,8 +349,6 @@ void QmlEngine::connectionEstablished()
connect(inspectorView(), &WatchTreeView::currentIndexChanged,
this, &QmlEngine::updateCurrentContext);
BreakpointManager::claimBreakpointsForEngine(this);
if (state() == EngineRunRequested)
notifyEngineRunAndInferiorRunOk();
}
@@ -2433,13 +2431,18 @@ void QmlEnginePrivate::stateChanged(State state)
engine->logServiceStateChange(name(), serviceVersion(), state);
if (state == QmlDebugClient::Enabled) {
/// Start session.
flushSendBuffer();
QJsonObject parameters;
parameters.insert("redundantRefs", false);
parameters.insert("namesAsObjects", false);
runDirectCommand(CONNECT, QJsonDocument(parameters).toJson());
runCommand({VERSION}, CB(handleVersion));
BreakpointManager::claimBreakpointsForEngine(engine);
// Since the breakpoint claiming is deferred, we need to also defer the connecting
QTimer::singleShot(0, this, [this]() {
/// Start session.
flushSendBuffer();
QJsonObject parameters;
parameters.insert("redundantRefs", false);
parameters.insert("namesAsObjects", false);
runDirectCommand(CONNECT, QJsonDocument(parameters).toJson());
runCommand({VERSION}, CB(handleVersion));
});
}
}