diff --git a/src/qml/jsruntime/qv4debugging.cpp b/src/qml/jsruntime/qv4debugging.cpp index 88db9df91a..6a8d364a08 100644 --- a/src/qml/jsruntime/qv4debugging.cpp +++ b/src/qml/jsruntime/qv4debugging.cpp @@ -74,7 +74,9 @@ public: ExecutionContext *ctx = engine->currentContext(); QV4::Script script(ctx, this->script); script.strictMode = ctx->d()->strictMode; - script.inheritContext = false; + // In order for property lookups in QML to work, we need to disable fast v4 lookups. That + // is a side-effect of inheritContext. + script.inheritContext = true; script.parse(); QV4::ScopedValue result(scope); if (!scope.engine->hasException) 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 #include +#include +#include #include #include #include @@ -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 debugThread(new QThread); + debugThread->start(); + QScopedPointer 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 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;