From 213fdd341038d5256a017555570e3359cf111001 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 8 Oct 2018 13:54:37 +0200 Subject: QML Tooling: Don't read properties in order to count them Reading properties may have side effects and we don't actually need the values here. Task-number: QTBUG-70989 Change-Id: If9f43f3c6a390ebd0ab1d1375fd021189adb10f7 Reviewed-by: Simon Hausmann --- .../qmldbg_debugger/qv4datacollector.cpp | 3 +- .../debugger/qqmldebugjs/data/breakOnAnchor.qml | 49 ++++++++++++++++++++++ .../auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro | 3 +- .../qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp | 39 +++++++++++++++++ 4 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 tests/auto/qml/debugger/qqmldebugjs/data/breakOnAnchor.qml diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp index 3dfb755936..73e9a1b219 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp @@ -154,10 +154,9 @@ const QV4::Object *collectProperty(const QV4::ScopedValue &value, QV4::Execution int numProperties = 0; QV4::ObjectIterator it(scope, o, QV4::ObjectIterator::EnumerableOnly); QV4::PropertyAttributes attrs; - QV4::ScopedProperty p(scope); QV4::ScopedPropertyKey name(scope); while (true) { - name = it.next(p, &attrs); + name = it.next(nullptr, &attrs); if (!name->isValid()) break; ++numProperties; diff --git a/tests/auto/qml/debugger/qqmldebugjs/data/breakOnAnchor.qml b/tests/auto/qml/debugger/qqmldebugjs/data/breakOnAnchor.qml new file mode 100644 index 0000000000..72a8c9559c --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebugjs/data/breakOnAnchor.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.11 + + +Item { + visible: true + Text { + anchors.centerIn: parent + text: "bla" + MouseArea { + anchors.fill: parent + } + } + + Timer { + interval: 100; + running: true; + onTriggered: { + Qt.quit(); + } + } +} diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro index b9d5f116dc..8fef435d98 100644 --- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro +++ b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro @@ -21,4 +21,5 @@ OTHER_FILES += data/test.qml data/test.js \ data/stepAction.qml \ data/breakpointRelocation.qml \ data/createComponent.qml \ - data/encodeQmlScope.qml + data/encodeQmlScope.qml \ + data/breakOnAnchor.qml diff --git a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp index c090be2633..2e2fda6746 100644 --- a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp +++ b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp @@ -127,6 +127,7 @@ const char *CHANGEBREAKPOINT_QMLFILE = "changeBreakpoint.qml"; const char *STEPACTION_QMLFILE = "stepAction.qml"; const char *BREAKPOINTRELOCATION_QMLFILE = "breakpointRelocation.qml"; const char *ENCODEQMLSCOPE_QMLFILE = "encodeQmlScope.qml"; +const char *BREAKONANCHOR_QMLFILE = "breakOnAnchor.qml"; #define VARIANTMAPINIT \ QString obj("{}"); \ @@ -224,6 +225,7 @@ private slots: void getScripts(); void encodeQmlScope(); + void breakOnAnchor(); private: ConnectResult init(bool qmlscene, const QString &qmlFile = QString(TEST_QMLFILE), @@ -1602,6 +1604,43 @@ void tst_QQmlDebugJS::encodeQmlScope() QCOMPARE(numReceivedScopes, numExpectedScopes); } +void tst_QQmlDebugJS::breakOnAnchor() +{ + QString file(BREAKONANCHOR_QMLFILE); + QCOMPARE(init(true, file), ConnectSuccess); + + int breaks = 0; + bool stopped = false; + QObject::connect(m_client, &QJSDebugClient::stopped, this, [&]() { + stopped = true; + ++breaks; + m_client->evaluate("this", 0, -1); + }); + + QObject::connect(m_client, &QJSDebugClient::result, this, [&]() { + if (stopped) { + m_client->continueDebugging(QJSDebugClient::Continue); + stopped = false; + } + }); + + QObject::connect(m_client, &QJSDebugClient::failure, this, [&]() { + qWarning() << "received failure" << m_client->response; + }); + + m_client->setBreakpoint(file, 34); + m_client->setBreakpoint(file, 37); + + QTRY_COMPARE(m_process->state(), QProcess::Running); + + m_client->connect(); + + QTRY_COMPARE(m_process->state(), QProcess::NotRunning); + QCOMPARE(m_process->exitStatus(), QProcess::NormalExit); + + QCOMPARE(breaks, 19); +} + QList tst_QQmlDebugJS::createClients() { m_client = new QJSDebugClient(m_connection); -- cgit v1.2.3