7#include <private/qqmldebugstatesdelegate_p.h>
8#include <private/qqmlboundsignal_p.h>
10#include <private/qqmlmetatype_p.h>
12#include <private/qqmlproperty_p.h>
13#include <private/qqmlbinding_p.h>
14#include <private/qqmlcontext_p.h>
15#include <private/qqmlvaluetype_p.h>
16#include <private/qqmlvmemetaobject_p.h>
17#include <private/qqmlexpression_p.h>
19#include <QtCore/qdebug.h>
20#include <QtCore/qmetaobject.h>
21#include <QtCore/qfileinfo.h>
22#include <QtCore/qjsonvalue.h>
23#include <QtCore/qjsonobject.h>
24#include <QtCore/qjsonarray.h>
25#include <QtCore/qjsondocument.h>
27#include <private/qmetaobject_p.h>
28#include <private/qqmldebugconnector_p.h>
29#include <private/qversionedpacket_p.h>
61 const int valType =
static_cast<int>(
value.userType());
73 this, &QQmlEngineDebugServiceImpl::propertyChanged);
82 delete m_statesDelegate;
108 ds <<
data.valueTypeName <<
data.binding <<
data.hasNotifySignal;
117 >>
data.binding >>
data.hasNotifySignal;
135 signalName[0] = signalName.
at(0).
toLower();
146QQmlEngineDebugServiceImpl::propertyData(
QObject *
obj,
int propIdx)
180 if (
value.userType() == qMetaTypeId<QJSValue>())
183 const int metaTypeId = metaType.
id();
188 if (
value.userType() == QMetaType::QVariantList) {
198 if (
value.userType() == QMetaType::QVariantMap) {
202 contents.insert(
i.key(), valueContents(
i.value()));
206 switch (metaTypeId) {
207 case QMetaType::QRect:
208 case QMetaType::QRectF:
209 case QMetaType::QPoint:
210 case QMetaType::QPointF:
211 case QMetaType::QSize:
212 case QMetaType::QSizeF:
213 case QMetaType::QFont:
216 case QMetaType::QJsonValue:
217 return value.toJsonValue().toVariant();
218 case QMetaType::QJsonObject:
219 return value.toJsonObject().toVariantMap();
220 case QMetaType::QJsonArray:
221 return value.toJsonArray().toVariantList();
222 case QMetaType::QJsonDocument:
223 return value.toJsonDocument().toVariant();
228 int toStringIndex =
mo->indexOfMethod(
"toString()");
229 if (toStringIndex != -1) {
256 QObject *
object,
bool recur,
bool dumpProperties)
262 int childrenCount = children.
size();
263 for (
int ii = 0; ii < children.
size(); ++ii) {
264 if (qobject_cast<QQmlContext*>(children[ii]))
268 message << childrenCount << recur;
272 for (
int ii = 0; ii < children.
size(); ++ii) {
274 if (qobject_cast<QQmlContext*>(
child))
282 if (!dumpProperties) {
288 for (
int ii = 0; ii <
object->metaObject()->propertyCount(); ++ii) {
289 if (
object->metaObject()->property(ii).isScriptable())
290 propertyIndexes << ii;
297 while (signalHandler) {
309 if (methodNameStr.size() != 0) {
311 + methodNameStr.mid(1);
315 fakeProperties << prop;
317 signalHandler = nextSignal(signalHandler);
323 for (
int ii = 0; ii < propertyIndexes.
size(); ++ii)
324 message << propertyData(
object, propertyIndexes.
at(ii));
326 for (
int ii = 0; ii < fakeProperties.
size(); ++ii)
330void QQmlEngineDebugServiceImpl::prepareDeferredObjects(
QObject *
obj)
335 for (
int ii = 0; ii < children.
size(); ++ii) {
337 prepareDeferredObjects(
child);
342void QQmlEngineDebugServiceImpl::storeObjectIds(
QObject *co)
346 for (
int ii = 0; ii < children.
size(); ++ii)
347 storeObjectIds(children.
at(ii));
376 child =
p->childContexts();
378 buildObjectList(
message,
child->asQQmlContext(), instances);
383 for (
int ii = 0; ii < instances.size(); ++ii) {
385 if (
data->context ==
p.data())
390 for (
int ii = 0; ii < instances.size(); ++ii) {
392 if (
data->context ==
p.data())
393 message << objectData(instances.at(ii));
397void QQmlEngineDebugServiceImpl::buildStatesList(
bool cleanList,
401 delegate->buildStatesList(cleanList, instances);
405QQmlEngineDebugServiceImpl::objectData(
QObject *
object)
439 int lineNumber,
int columnNumber)
449 objects <<
i.value();
466 if (
type ==
"LIST_ENGINES") {
470 for (
int ii = 0; ii < m_engines.
size(); ++ii) {
476 rs << engineName << engineId;
479 }
else if (
type ==
"LIST_OBJECTS") {
493 buildObjectList(rs, rootContext, instances);
494 buildStatesList(
true, instances);
497 }
else if (
type ==
"FETCH_OBJECT") {
500 bool dumpProperties =
true;
502 ds >> objectId >> recurse >> dumpProperties;
510 prepareDeferredObjects(
object);
511 buildObjectDump(rs,
object, recurse, dumpProperties);
514 }
else if (
type ==
"FETCH_OBJECTS_FOR_LOCATION") {
519 bool dumpProperties =
true;
521 ds >>
file >> lineNumber >> columnNumber >> recurse >> dumpProperties;
526 << int(objects.
size());
528 for (
QObject *
object : objects) {
530 prepareDeferredObjects(
object);
531 buildObjectDump(rs,
object, recurse, dumpProperties);
534 }
else if (
type ==
"WATCH_OBJECT") {
542 }
else if (
type ==
"WATCH_PROPERTY") {
551 }
else if (
type ==
"WATCH_EXPR_OBJECT") {
555 ds >> debugId >> expr;
560 }
else if (
type ==
"NO_WATCH") {
565 }
else if (
type ==
"EVAL_EXPRESSION") {
569 ds >> objectId >> expr;
585 bool undefined =
false;
597 }
else if (
type ==
"SET_BINDING") {
604 ds >> objectId >> propertyName >> expr >> isLiteralValue >>
606 bool ok = setBinding(objectId, propertyName, expr, isLiteralValue,
611 }
else if (
type ==
"RESET_BINDING") {
614 ds >> objectId >> propertyName;
615 bool ok = resetBinding(objectId, propertyName);
619 }
else if (
type ==
"SET_METHOD_BODY") {
624 bool ok = setMethodBody(objectId,
methodName, methodBody);
632bool QQmlEngineDebugServiceImpl::setBinding(
int objectId,
641 QObject *
object = objectForId(objectId);
648 bool inBaseState =
true;
655 if (isLiteralValue) {
656 property.write(expression);
669 qWarning() <<
"QQmlEngineDebugService::setBinding: unable to set property" << propertyName <<
"on object" <<
object;
676 ok = delegate->setBindingForInvalidProperty(
object, propertyName, expression, isLiteralValue);
678 qWarning() <<
"QQmlEngineDebugService::setBinding: unable to set property" << propertyName <<
"on object" <<
object;
684bool QQmlEngineDebugServiceImpl::resetBinding(
int objectId,
const QString &propertyName)
686 QObject *
object = objectForId(objectId);
691 const int idx = parentPropertyRef.indexOf(
QLatin1Char(
'.'));
693 parentPropertyRef = parentPropertyRef.left(idx);
695 const QByteArray parentProperty = parentPropertyRef.toLatin1();
696 if (
object->property(parentProperty).isValid()) {
710 if (emptyObject->property(parentProperty).isValid()) {
713 setBinding(objectId, propertyName, defaultValue,
true);
730 delegate->resetBindingForInvalidProperty(
object, propertyName);
740bool QQmlEngineDebugServiceImpl::setMethodBody(
int objectId,
const QString &
method,
const QString &body)
742 QObject *
object = objectForId(objectId);
758 for (
int ii = 0; ii < paramNames.
size(); ++ii) {
774 if (oldMethod && oldMethod->d()->function)
775 lineNumber = oldMethod->d()->function->compiledFunction->location.line();
782void QQmlEngineDebugServiceImpl::propertyChanged(
821 rs <<
QByteArray(
"OBJECT_CREATED") <<
qint32(-1) << engineId << objectId << parentId;
827#include "moc_qqmlenginedebugservice.cpp"
qint64 writeData(const char *data, qint64 len) final
Writes up to maxSize bytes from data to the device.
qint64 readData(char *data, qint64 maxlen) final
Reads up to maxSize bytes from the device into data, and returns the number of bytes read or -1 if an...
QChar toLower() const noexcept
Returns the lowercase equivalent if the character is uppercase or titlecase; otherwise returns the ch...
constexpr bool isUpper() const noexcept
Returns true if the character is an uppercase letter, for example category() is Letter_Uppercase.
QChar toUpper() const noexcept
Returns the uppercase equivalent if the character is lowercase or titlecase; otherwise returns the ch...
constexpr bool isLetter() const noexcept
Returns true if the character is a letter (Letter_* categories); otherwise returns false.
\inmodule QtCore\reentrant
\inmodule QtCore \reentrant
QString fileName() const
Returns the name of the file, excluding the path.
\inmodule QtCore \reentrant
virtual bool open(QIODeviceBase::OpenMode mode)
Opens the device and sets its OpenMode to mode.
The QJSEngine class provides an environment for evaluating JavaScript code.
QV4::ExecutionEngine * handle() const
The QJSValue class acts as a container for Qt/JavaScript data types.
qsizetype size() const noexcept
QList< T > toList() const noexcept
const_reference at(qsizetype i) const noexcept
qsizetype removeAll(const AT &t)
void append(parameter_type t)
const_iterator cend() const
const_iterator cbegin() const
const QObjectList & children() const
Returns a list of child objects.
QString objectName
the name of this object
const QByteArray & data() const
Returns a reference to the raw packet data.
void setTarget(const QQmlProperty &)
virtual QString expression() const
void update(QQmlPropertyData::WriteFlags flags=QQmlPropertyData::DontRemoveBinding)
static QQmlBinding * create(const QQmlPropertyData *, const QQmlScriptString &, QObject *, QQmlContext *)
QString expression() const
QQmlBoundSignalExpression * expression() const
Returns the signal expression.
QString findObjectId(const QObject *obj) const
static QQmlRefPointer< QQmlContextData > get(QQmlContext *context)
QString urlString() const
static QQmlContextPrivate * get(QQmlContext *context)
QList< QPointer< QObject > > instances() const
The QQmlContext class defines a context within a QML engine.
bool isValid() const
Returns whether the context is valid.
QObject * contextObject() const
Return the context object, or \nullptr if there is no context object.
QQmlBoundSignal * signalHandlers
static QQmlData * get(QObjectPrivate *priv, bool create)
QQmlContextData * outerContext
static int idForObject(QObject *)
Returns a unique id for object.
static QObject * objectForId(int id)
void objectCreated(QJSEngine *, QObject *) override
void engineAboutToBeAdded(QJSEngine *) override
void messageReceived(const QByteArray &) override
QQmlEngineDebugServiceImpl(QObject *=nullptr)
void scheduleMessage(const QByteArray &)
~QQmlEngineDebugServiceImpl()
void engineAboutToBeRemoved(QJSEngine *) override
QQmlDebugStatesDelegate * statesDelegate()
The QQmlEngine class provides an environment for instantiating QML components.
The QQmlExpression class evaluates JavaScript in a QML context.
QObject * scopeObject() const
static QV4::ReturnedValue evalFunction(const QQmlRefPointer< QQmlContextData > &ctxt, QObject *scope, const QString &code, const QString &filename, quint16 line)
const QQmlPropertyData * property(const K &key, QObject *object, const QQmlRefPointer< QQmlContextData > &context) const
bool isVMEFunction() const
static void takeSignalExpression(const QQmlProperty &that, QQmlBoundSignalExpression *)
Set the signal expression associated with this signal property to expr.
static void setBinding(QQmlAbstractBinding *binding, BindingFlags flags=None, QQmlPropertyData::WriteFlags writeFlags=QQmlPropertyData::DontRemoveBinding)
static void removeBinding(const QQmlProperty &that)
static void setSignalExpression(const QQmlProperty &that, QQmlBoundSignalExpression *)
Set the signal expression associated with this signal property to expr.
static QQmlPropertyPrivate * get(const QQmlProperty &p)
static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &)
Return the signal corresponding to name.
static QQmlAbstractBinding * binding(QObject *, QQmlPropertyIndex index)
The QQmlProperty class abstracts accessing properties on objects created from QML.
QVariant read() const
Returns the property value.
bool addWatch(int id, quint32 objectId)
void propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value)
\macro QT_RESTRICTED_CAST_FROM_ASCII
QByteArray toLatin1() const &
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
qsizetype size() const
Returns the number of characters in this string.
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
QString & append(QChar c)
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
QHash< int, QWidget * > hash
[35multi]
QMap< QString, QString > map
[6]
Combined button and popup list for selecting options.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char * method
static QString methodName(const QDBusIntrospection::Method &method)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_RETURN_ARG(Type, data)
GLsizei const GLfloat * v
[13]
GLenum GLenum GLsizei count
GLuint GLsizei const GLchar * message
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei void GLsizei void * column
void qmlExecuteDeferred(QObject *object)
QQmlEngine * qmlEngine(const QObject *obj)
QQmlContext * qmlContext(const QObject *obj)
static bool isSaveable(const QVariant &value)
static bool hasValidSignal(QObject *object, const QString &propertyName)
static bool isSignalPropertyName(const QString &signalName)
QDataStream & operator>>(QDataStream &ds, QQmlEngineDebugServiceImpl::QQmlObjectData &data)
QDataStream & operator<<(QDataStream &ds, const QQmlEngineDebugServiceImpl::QQmlObjectData &data)
QLatin1StringView QLatin1String
#define QStringLiteral(str)
static QVariant toVariant(const QV4::Value &value, QMetaType typeHint, bool createJSValueForObjectsAndSymbols, V4ObjectSet *visitedObjects)
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
\inmodule QtCore \reentrant
bool contains(const AT &t) const noexcept
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent