aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2018-10-08 13:54:37 +0200
committerUlf Hermann <ulf.hermann@qt.io>2018-10-10 12:44:03 +0000
commit213fdd341038d5256a017555570e3359cf111001 (patch)
treed43ad8a20360a73e6a3d90a04e697b04a8899f75
parent3833e9631a03a5cffd52e198e01b094fdfead30c (diff)
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 <simon.hausmann@qt.io>
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp3
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/breakOnAnchor.qml49
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro3
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp39
4 files changed, 91 insertions, 3 deletions
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<QQmlDebugClient *> tst_QQmlDebugJS::createClients()
{
m_client = new QJSDebugClient(m_connection);