diff options
Diffstat (limited to 'src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp')
-rw-r--r-- | src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp | 102 |
1 files changed, 28 insertions, 74 deletions
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp index 962245fa4c..3bd37878a8 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** 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-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qqmlenginedebugservice.h" #include "qqmlwatcher.h" @@ -51,6 +15,7 @@ #include <private/qqmlvaluetype_p.h> #include <private/qqmlvmemetaobject_p.h> #include <private/qqmlexpression_p.h> +#include <private/qqmlsignalnames_p.h> #include <QtCore/qdebug.h> #include <QtCore/qmetaobject.h> @@ -155,22 +120,14 @@ QDataStream &operator>>(QDataStream &ds, return ds; } -static inline bool isSignalPropertyName(const QString &signalName) -{ - // see QmlCompiler::isSignalPropertyName - return signalName.length() >= 3 && signalName.startsWith(QLatin1String("on")) && - signalName.at(2).isLetter() && signalName.at(2).isUpper(); -} - static bool hasValidSignal(QObject *object, const QString &propertyName) { - if (!isSignalPropertyName(propertyName)) + auto signalName = QQmlSignalNames::handlerNameToSignalName(propertyName); + if (!signalName) return false; - QString signalName = propertyName.mid(2); - signalName[0] = signalName.at(0).toLower(); - - int sigIdx = QQmlPropertyPrivate::findSignalByName(object->metaObject(), signalName.toLatin1()).methodIndex(); + int sigIdx = QQmlPropertyPrivate::findSignalByName(object->metaObject(), signalName->toLatin1()) + .methodIndex(); if (sigIdx == -1) return false; @@ -198,7 +155,7 @@ QQmlEngineDebugServiceImpl::propertyData(QObject *obj, int propIdx) if (prop.metaType().flags().testFlag(QMetaType::PointerToQObject)) { rv.type = QQmlObjectProperty::Object; - } else if (QQmlMetaType::isList(prop.userType())) { + } else if (QQmlMetaType::isList(prop.metaType())) { rv.type = QQmlObjectProperty::List; } else if (prop.userType() == QMetaType::QVariant) { rv.type = QQmlObjectProperty::Variant; @@ -259,7 +216,7 @@ QVariant QQmlEngineDebugServiceImpl::valueContents(QVariant value) const return value.toJsonDocument().toVariant(); default: if (QQmlMetaType::isValueType(metaType)) { - const QMetaObject *mo = QQmlMetaType::metaObjectForMetaType(metaType); + const QMetaObject *mo = QQmlMetaType::metaObjectForValueType(metaType); if (mo) { int toStringIndex = mo->indexOfMethod("toString()"); if (toStringIndex != -1) { @@ -295,8 +252,8 @@ void QQmlEngineDebugServiceImpl::buildObjectDump(QDataStream &message, QObjectList children = object->children(); - int childrenCount = children.count(); - for (int ii = 0; ii < children.count(); ++ii) { + int childrenCount = children.size(); + for (int ii = 0; ii < children.size(); ++ii) { if (qobject_cast<QQmlContext*>(children[ii])) --childrenCount; } @@ -305,7 +262,7 @@ void QQmlEngineDebugServiceImpl::buildObjectDump(QDataStream &message, QList<QQmlObjectProperty> fakeProperties; - for (int ii = 0; ii < children.count(); ++ii) { + for (int ii = 0; ii < children.size(); ++ii) { QObject *child = children.at(ii); if (qobject_cast<QQmlContext*>(child)) continue; @@ -341,10 +298,8 @@ void QQmlEngineDebugServiceImpl::buildObjectDump(QDataStream &message, if (scope) { const QByteArray methodName = QMetaObjectPrivate::signal(scope->metaObject(), signalHandler->signalIndex()).name(); - const QLatin1String methodNameStr(methodName); - if (methodNameStr.size() != 0) { - prop.name = QLatin1String("on") + QChar(methodNameStr.at(0)).toUpper() - + methodNameStr.mid(1); + if (!methodName.isEmpty()) { + prop.name = QQmlSignalNames::signalNameToHandlerName(methodName); } } } @@ -354,12 +309,12 @@ void QQmlEngineDebugServiceImpl::buildObjectDump(QDataStream &message, } } - message << int(propertyIndexes.size() + fakeProperties.count()); + message << int(propertyIndexes.size() + fakeProperties.size()); for (int ii = 0; ii < propertyIndexes.size(); ++ii) message << propertyData(object, propertyIndexes.at(ii)); - for (int ii = 0; ii < fakeProperties.count(); ++ii) + for (int ii = 0; ii < fakeProperties.size(); ++ii) message << fakeProperties[ii]; } @@ -368,7 +323,7 @@ void QQmlEngineDebugServiceImpl::prepareDeferredObjects(QObject *obj) qmlExecuteDeferred(obj); QObjectList children = obj->children(); - for (int ii = 0; ii < children.count(); ++ii) { + for (int ii = 0; ii < children.size(); ++ii) { QObject *child = children.at(ii); prepareDeferredObjects(child); } @@ -379,7 +334,7 @@ void QQmlEngineDebugServiceImpl::storeObjectIds(QObject *co) { QQmlDebugService::idForObject(co); QObjectList children = co->children(); - for (int ii = 0; ii < children.count(); ++ii) + for (int ii = 0; ii < children.size(); ++ii) storeObjectIds(children.at(ii)); } @@ -416,14 +371,14 @@ void QQmlEngineDebugServiceImpl::buildObjectList(QDataStream &message, } count = 0; - for (int ii = 0; ii < instances.count(); ++ii) { + for (int ii = 0; ii < instances.size(); ++ii) { QQmlData *data = QQmlData::get(instances.at(ii)); if (data->context == p.data()) count ++; } message << count; - for (int ii = 0; ii < instances.count(); ++ii) { + for (int ii = 0; ii < instances.size(); ++ii) { QQmlData *data = QQmlData::get(instances.at(ii)); if (data->context == p.data()) message << objectData(instances.at(ii)); @@ -501,9 +456,9 @@ void QQmlEngineDebugServiceImpl::processMessage(const QByteArray &message) if (type == "LIST_ENGINES") { rs << QByteArray("LIST_ENGINES_R"); - rs << queryId << int(m_engines.count()); + rs << queryId << int(m_engines.size()); - for (int ii = 0; ii < m_engines.count(); ++ii) { + for (int ii = 0; ii < m_engines.size(); ++ii) { QJSEngine *engine = m_engines.at(ii); QString engineName = engine->objectName(); @@ -559,7 +514,7 @@ void QQmlEngineDebugServiceImpl::processMessage(const QByteArray &message) const QList<QObject*> objects = objectForLocationInfo(file, lineNumber, columnNumber); rs << QByteArray("FETCH_OBJECTS_FOR_LOCATION_R") << queryId - << int(objects.count()); + << int(objects.size()); for (QObject *object : objects) { if (recurse) @@ -782,8 +737,7 @@ bool QQmlEngineDebugServiceImpl::setMethodBody(int objectId, const QString &meth QQmlRefPointer<QQmlContextData> contextData = QQmlContextData::get(context); QQmlPropertyData dummy; - QQmlPropertyData *prop = - QQmlPropertyCache::property(context->engine(), object, method, contextData, &dummy); + const QQmlPropertyData *prop = QQmlPropertyCache::property(object, method, contextData, &dummy); if (!prop || !prop->isVMEFunction()) return false; @@ -792,7 +746,7 @@ bool QQmlEngineDebugServiceImpl::setMethodBody(int objectId, const QString &meth QList<QByteArray> paramNames = metaMethod.parameterNames(); QString paramStr; - for (int ii = 0; ii < paramNames.count(); ++ii) { + for (int ii = 0; ii < paramNames.size(); ++ii) { if (ii != 0) paramStr.append(QLatin1Char(',')); paramStr.append(QString::fromUtf8(paramNames.at(ii))); } @@ -808,9 +762,9 @@ bool QQmlEngineDebugServiceImpl::setMethodBody(int objectId, const QString &meth int lineNumber = 0; QV4::ScopedFunctionObject oldMethod(scope, vmeMetaObject->vmeMethod(prop->coreIndex())); - if (oldMethod && oldMethod->d()->function) { - lineNumber = oldMethod->d()->function->compiledFunction->location.line; - } + if (oldMethod && oldMethod->d()->function) + lineNumber = oldMethod->d()->function->compiledFunction->location.line(); + QV4::ScopedValue v(scope, QQmlJavaScriptExpression::evalFunction(contextData, object, jsfunction, contextData->urlString(), lineNumber)); vmeMetaObject->setVmeMethod(prop->coreIndex(), v); return true; |