From 522ba308978ba52d09930a3ea8177f7f86c7ae63 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 18 Jul 2018 15:41:09 +0200 Subject: [PATCH] V4 Debugger: Use changebreakpoint command if available Newer versions of QML will support proper changing of break points, we won't need to work around it anymore. Task-number: QTCREATORBUG-20795 Change-Id: Idb5aaeb8ea59c7d2fd7c924e336ea259d3573d3d Reviewed-by: hjk --- src/plugins/debugger/qml/qmlengine.cpp | 26 +++++++++++++++++-- .../qml/qmlv8debuggerclientconstants.h | 1 + 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index ef6d38650f1..21cdbdd141d 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -170,6 +170,10 @@ public: bool enabled = true,int line = 0, int column = 0, const QString condition = QString(), int ignoreCount = -1); void clearBreakpoint(int breakpoint); + + bool canChangeBreakpoint() const; + void changeBreakpoint(int breakpoint, bool enabled); + void setExceptionBreak(Exceptions type, bool enabled = false); void flushSendBuffer(); @@ -225,6 +229,7 @@ public: bool automaticConnect = false; bool unpausedEvaluate = false; bool contextEvaluate = false; + bool supportChangeBreakpoint = false; QTimer connectionTimer; QmlDebug::QDebugMessageClient *msgClient = nullptr; @@ -759,6 +764,8 @@ void QmlEngine::changeBreakpoint(Breakpoint bp) d->setBreakpoint(EVENT, params.functionName, params.enabled); br.enabled = params.enabled; bp.setResponse(br); + } else if (d->canChangeBreakpoint()) { + d->changeBreakpoint(d->breakpoints.value(bp.id()), params.enabled); } else { //V8 supports only minimalistic changes in breakpoint //Remove the breakpoint and add again @@ -1502,6 +1509,19 @@ void QmlEnginePrivate::clearBreakpoint(int breakpoint) runCommand(cmd); } +bool QmlEnginePrivate::canChangeBreakpoint() const +{ + return supportChangeBreakpoint; +} + +void QmlEnginePrivate::changeBreakpoint(int breakpoint, bool enabled) +{ + DebuggerCommand cmd(CHANGEBREAKPOINT); + cmd.arg(BREAKPOINT, breakpoint); + cmd.arg(ENABLED, enabled); + runCommand(cmd); +} + void QmlEnginePrivate::setExceptionBreak(Exceptions type, bool enabled) { // { "seq" : , @@ -2478,8 +2498,10 @@ void QmlEnginePrivate::stateChanged(State state) void QmlEnginePrivate::handleVersion(const QVariantMap &response) { - unpausedEvaluate = response.value(BODY).toMap().value("UnpausedEvaluate", false).toBool(); - contextEvaluate = response.value(BODY).toMap().value("ContextEvaluate", false).toBool(); + const QVariantMap body = response.value(BODY).toMap(); + unpausedEvaluate = body.value("UnpausedEvaluate", false).toBool(); + contextEvaluate = body.value("ContextEvaluate", false).toBool(); + supportChangeBreakpoint = body.value("ChangeBreakpoint", false).toBool(); } void QmlEnginePrivate::flushSendBuffer() diff --git a/src/plugins/debugger/qml/qmlv8debuggerclientconstants.h b/src/plugins/debugger/qml/qmlv8debuggerclientconstants.h index 90c585b8e3a..3056dd74f92 100644 --- a/src/plugins/debugger/qml/qmlv8debuggerclientconstants.h +++ b/src/plugins/debugger/qml/qmlv8debuggerclientconstants.h @@ -73,6 +73,7 @@ const char SCOPE[] = "scope"; const char SCRIPTS[] = "scripts"; const char SETBREAKPOINT[] = "setbreakpoint"; const char CLEARBREAKPOINT[] = "clearbreakpoint"; +const char CHANGEBREAKPOINT[] = "changebreakpoint"; const char SETEXCEPTIONBREAK[] = "setexceptionbreak"; const char VERSION[] = "version"; const char DISCONNECT[] = "disconnect";