diff options
author | Kai Koehne <kai.koehne@nokia.com> | 2011-08-09 09:46:23 (GMT) |
---|---|---|
committer | Kai Koehne <kai.koehne@nokia.com> | 2011-08-10 12:34:23 (GMT) |
commit | 3322d45ca0c368d3c820878122b2041828e5778c (patch) | |
tree | c321e682ec5ffdf33c7d6da481cecda7239cbfbd /src/declarative/debugger/qjsdebuggeragent.cpp | |
parent | ed54c64af0d61d6bfea2ec87428ba5d008a30564 (diff) | |
download | Qt-3322d45ca0c368d3c820878122b2041828e5778c.zip Qt-3322d45ca0c368d3c820878122b2041828e5778c.tar.gz Qt-3322d45ca0c368d3c820878122b2041828e5778c.tar.bz2 |
JSDebugger: Only hit breakpoints in user code
Check that the topmost stack entry is a user defined ScriptFunction.
This avoids hitting the anonymous functions used for bindings, e.g.
onClicked: Qt.quit()
leads to script code
(function onClicked() { Qt.quit(); })
which will be hit twice for the debugger: Once for the function call
itself, then for the execution of Qt.quit().
Change-Id: Id431cacaef84172dc3474018cdf61f3dcc05cf93
Diffstat (limited to 'src/declarative/debugger/qjsdebuggeragent.cpp')
-rw-r--r-- | src/declarative/debugger/qjsdebuggeragent.cpp | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/src/declarative/debugger/qjsdebuggeragent.cpp b/src/declarative/debugger/qjsdebuggeragent.cpp index 683032b..308fe17 100644 --- a/src/declarative/debugger/qjsdebuggeragent.cpp +++ b/src/declarative/debugger/qjsdebuggeragent.cpp @@ -511,27 +511,24 @@ void QJSDebuggerAgentPrivate::positionChange(qint64 scriptId, int lineNumber, in // check breakpoints if (!breakpoints.isEmpty()) { - QHash<qint64, QString>::const_iterator it = filenames.constFind(scriptId); - QScriptContext *ctx = engine()->currentContext(); - QScriptContextInfo info(ctx); - if (it == filenames.constEnd()) { - // It is possible that the scripts are loaded before the agent is attached - QString filename = info.fileName(); + const QScriptContext *ctx = engine()->currentContext(); + const QScriptContextInfo info(ctx); - JSAgentStackData frame; - frame.functionName = info.functionName().toUtf8(); - - QPair<QString, qint32> key = qMakePair(filename, lineNumber); - it = filenames.insert(scriptId, filename); - } + if (info.functionType() == QScriptContextInfo::ScriptFunction) { + QHash<qint64, QString>::const_iterator it = filenames.constFind(scriptId); + // It is possible that the scripts are loaded before the agent is attached + if (it == filenames.constEnd()) { + it = filenames.insert(scriptId, info.fileName()); + } - const QString filePath = it.value(); - JSAgentBreakpoints bps = fileNameToBreakpoints.values(fileName(filePath)).toSet(); + const QString filePath = it.value(); + JSAgentBreakpoints bps = fileNameToBreakpoints.values(fileName(filePath)).toSet(); - foreach (const JSAgentBreakpointData &bp, bps) { - if (bp.lineNumber == lineNumber) { - stopped(); - return; + foreach (const JSAgentBreakpointData &bp, bps) { + if (bp.lineNumber == lineNumber) { + stopped(); + return; + } } } } |