diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2014-12-01 15:51:05 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-12-03 08:28:25 +0100 |
commit | a6fbea98ed3c2cce4bd1b2d4ec2dc055b4eaf129 (patch) | |
tree | 3cd715b70f268a1c19c69d9649cff8196aee11e3 /tests/auto/qml/qv4debugger | |
parent | cfdcc65cc54fc973a147044fc592779e87a669c4 (diff) |
Fix conditional breakpoints in QML
We need to set "inheritContext" to true for the QV4::Script that's used during
conditional break point evaluation, because that will also disable fast
property lookups, which is still required for QML lookups to work.
Change-Id: I8976df1c827b5058eae9bdce6e86e5ea856cbfe1
Task-number: QTBUG-43018
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests/auto/qml/qv4debugger')
-rw-r--r-- | tests/auto/qml/qv4debugger/tst_qv4debugger.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp index 6457cb7898..63bfffacaa 100644 --- a/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp +++ b/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp @@ -33,6 +33,8 @@ #include <QtTest/QtTest> #include <QJSEngine> +#include <QQmlEngine> +#include <QQmlComponent> #include <private/qv4engine_p.h> #include <private/qv4debugging_p.h> #include <private/qv8engine_p.h> @@ -274,6 +276,7 @@ private slots: void addBreakPointWhilePaused(); void removeBreakPointForNextInstruction(); void conditionalBreakPoint(); + void conditionalBreakPointInQml(); // context access: void readArguments(); @@ -445,6 +448,42 @@ void tst_qv4debugger::conditionalBreakPoint() QCOMPARE(m_debuggerAgent->m_capturedLocals[0]["i"].toInt(), 11); } +void tst_qv4debugger::conditionalBreakPointInQml() +{ + QQmlEngine engine; + QV4::ExecutionEngine *v4 = QV8Engine::getV4(&engine); + v4->enableDebugger(); + + QScopedPointer<QThread> debugThread(new QThread); + debugThread->start(); + QScopedPointer<TestAgent> debuggerAgent(new TestAgent); + debuggerAgent->addDebugger(v4->debugger); + debuggerAgent->moveToThread(debugThread.data()); + + QQmlComponent component(&engine); + component.setData("import QtQml 2.0\n" + "QtObject {\n" + " id: root\n" + " property int foo: 42\n" + " property bool success: false\n" + " Component.onCompleted: {\n" + " success = true;\n" // breakpoint here + " }\n" + "}\n", QUrl("test.qml")); + + debuggerAgent->addBreakPoint("test.qml", 7, /*enabled*/true, "root.foo == 42"); + + QScopedPointer<QObject> obj(component.create()); + QCOMPARE(obj->property("success").toBool(), true); + + QCOMPARE(debuggerAgent->m_statesWhenPaused.count(), 1); + QCOMPARE(debuggerAgent->m_statesWhenPaused.at(0).fileName, QStringLiteral("test.qml")); + QCOMPARE(debuggerAgent->m_statesWhenPaused.at(0).lineNumber, 7); + + debugThread->quit(); + debugThread->wait(); +} + void tst_qv4debugger::readArguments() { m_debuggerAgent->m_captureContextInfo = true; |