Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqmlenginedebugclient.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5#include <private/qqmldebugconnection_p.h>
6
8
20
22{
23 ds >> data.url >> data.lineNumber >> data.columnNumber >> data.idString
24 >> data.objectName >> data.objectType >> data.objectId >> data.contextId
25 >> data.parentId;
26 return ds;
27}
28
38
40{
42 ds >> type >> data.name >> data.value >> data.valueTypeName
43 >> data.binding >> data.hasNotifySignal;
45 return ds;
46}
47
52
57
58
60 const QQmlEngineDebugPropertyReference &property, bool *success)
61{
62 qint32 id = -1;
63 *success = false;
65 id = getId();
66 QPacket ds(connection()->currentDataStreamVersion());
67 ds << QByteArray("WATCH_PROPERTY") << id << property.objectDebugId
68 << property.name.toUtf8();
69 sendMessage(ds.data());
70 *success = true;
71 }
72 return id;
73}
74
76 const QQmlEngineDebugContextReference &, const QString &, bool *success)
77{
78 *success = false;
79 qWarning("QQmlEngineDebugClient::addWatch(): Not implemented");
80 return -1;
81}
82
84 const QQmlEngineDebugObjectReference &object, const QString &expr,
85 bool *success)
86{
87 qint32 id = -1;
88 *success = false;
90 id = getId();
91 QPacket ds(connection()->currentDataStreamVersion());
92 ds << QByteArray("WATCH_EXPR_OBJECT") << id << object.debugId << expr;
93 sendMessage(ds.data());
94 *success = true;
95 }
96 return id;
97}
98
100 const QQmlEngineDebugObjectReference &object, bool *success)
101{
102 qint32 id = -1;
103 *success = false;
105 id = getId();
106 QPacket ds(connection()->currentDataStreamVersion());
107 ds << QByteArray("WATCH_OBJECT") << id << object.debugId;
108 sendMessage(ds.data());
109 *success = true;
110 }
111 return id;
112}
113
115 const QQmlEngineDebugFileReference &, bool *success)
116{
117 *success = false;
118 qWarning("QQmlEngineDebugClient::addWatch(): Not implemented");
119 return -1;
120}
121
123{
124 *success = false;
126 QPacket ds(connection()->currentDataStreamVersion());
127 ds << QByteArray("NO_WATCH") << id;
128 sendMessage(ds.data());
129 *success = true;
130 }
131}
132
134{
136 d->engines.clear();
137 qint32 id = -1;
138 *success = false;
140 id = getId();
141 QPacket ds(connection()->currentDataStreamVersion());
142 ds << QByteArray("LIST_ENGINES") << id;
143 sendMessage(ds.data());
144 *success = true;
145 }
146 return id;
147}
148
150 const QQmlEngineDebugEngineReference &engine, bool *success)
151{
153 d->rootContext = QQmlEngineDebugContextReference();
154 qint32 id = -1;
155 *success = false;
156 if (state() == QQmlDebugClient::Enabled && engine.debugId != -1) {
157 id = getId();
158 QPacket ds(connection()->currentDataStreamVersion());
159 ds << QByteArray("LIST_OBJECTS") << id << engine.debugId;
160 sendMessage(ds.data());
161 *success = true;
162 }
163 return id;
164}
165
167 const QQmlEngineDebugObjectReference &object, bool *success)
168{
171 qint32 id = -1;
172 *success = false;
173 if (state() == QQmlDebugClient::Enabled && object.debugId != -1) {
174 id = getId();
175 QPacket ds(connection()->currentDataStreamVersion());
176 ds << QByteArray("FETCH_OBJECT") << id << object.debugId << false << true;
177 sendMessage(ds.data());
178 *success = true;
179 }
180 return id;
181}
182
184 const QString &file, qint32 lineNumber, qint32 columnNumber, bool *success)
185{
187 d->objects.clear();
188 qint32 id = -1;
189 *success = false;
191 id = getId();
192 QPacket ds(connection()->currentDataStreamVersion());
193 ds << QByteArray("FETCH_OBJECTS_FOR_LOCATION") << id << file << lineNumber
194 << columnNumber << false << true;
195 sendMessage(ds.data());
196 *success = true;
197 }
198 return id;
199}
200
202 const QQmlEngineDebugObjectReference &object, bool *success)
203{
206 qint32 id = -1;
207 *success = false;
208 if (state() == QQmlDebugClient::Enabled && object.debugId != -1) {
209 id = getId();
210 QPacket ds(connection()->currentDataStreamVersion());
211 ds << QByteArray("FETCH_OBJECT") << id << object.debugId << true << true;
212 sendMessage(ds.data());
213 *success = true;
214 }
215 return id;
216}
217
219 qint32 lineNumber, qint32 columnNumber, bool *success)
220{
222 d->objects.clear();
223 qint32 id = -1;
224 *success = false;
226 id = getId();
227 QPacket ds(connection()->currentDataStreamVersion());
228 ds << QByteArray("FETCH_OBJECTS_FOR_LOCATION") << id << file << lineNumber
229 << columnNumber << true << true;
230 sendMessage(ds.data());
231 *success = true;
232 }
233 return id;
234}
235
237 qint32 objectDebugId, const QString &expr, bool *success)
238{
240 d->exprResult = QVariant();
241 qint32 id = -1;
242 *success = false;
244 id = getId();
245 QPacket ds(connection()->currentDataStreamVersion());
246 ds << QByteArray("EVAL_EXPRESSION") << id << objectDebugId << expr
247 << engines()[0].debugId;
248 sendMessage(ds.data());
249 *success = true;
250 }
251 return id;
252}
253
255 qint32 objectDebugId, const QString &expr, bool *success)
256{
258 d->exprResult = QVariant();
259 qint32 id = -1;
260 *success = false;
262 id = getId();
263 QPacket ds(connection()->currentDataStreamVersion());
264 ds << QByteArray("EVAL_EXPRESSION") << id << objectDebugId << expr;
265 sendMessage(ds.data());
266 *success = true;
267 }
268 return id;
269}
270
272 qint32 objectDebugId,
273 const QString &propertyName,
274 const QVariant &bindingExpression,
275 bool isLiteralValue,
276 const QString &source, qint32 line,
277 bool *success)
278{
279 qint32 id = -1;
280 *success = false;
281 if (state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
282 id = getId();
283 QPacket ds(connection()->currentDataStreamVersion());
284 ds << QByteArray("SET_BINDING") << id << objectDebugId << propertyName
285 << bindingExpression << isLiteralValue << source << line;
286 sendMessage(ds.data());
287 *success = true;
288 }
289 return id;
290}
291
293 qint32 objectDebugId,
294 const QString &propertyName,
295 bool *success)
296{
297 qint32 id = -1;
298 *success = false;
299 if (state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
300 id = getId();
301 QPacket ds(connection()->currentDataStreamVersion());
302 ds << QByteArray("RESET_BINDING") << id << objectDebugId << propertyName;
303 sendMessage(ds.data());
304 *success = true;
305 }
306 return id;
307}
308
310 qint32 objectDebugId, const QString &methodName,
311 const QString &methodBody, bool *success)
312{
313 qint32 id = -1;
314 *success = false;
315 if (state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
316 id = getId();
317 QPacket ds(connection()->currentDataStreamVersion());
318 ds << QByteArray("SET_METHOD_BODY") << id << objectDebugId
319 << methodName << methodBody;
320 sendMessage(ds.data());
321 *success = true;
322 }
323 return id;
324}
325
328 bool simple)
329{
331 ds >> data;
332 o.debugId = data.objectId;
333 o.className = data.objectType;
334 o.idString = data.idString;
335 o.name = data.objectName;
336 o.source.url = data.url;
337 o.source.lineNumber = data.lineNumber;
338 o.source.columnNumber = data.columnNumber;
339 o.contextDebugId = data.contextId;
340
341 if (simple)
342 return;
343
344 qint32 childCount;
345 bool recur;
346 ds >> childCount >> recur;
347
348 for (qint32 ii = 0; ii < childCount; ++ii) {
349 o.children.append(QQmlEngineDebugObjectReference());
350 decode(ds, o.children.last(), !recur);
351 }
352
354 ds >> propCount;
355
356 for (qint32 ii = 0; ii < propCount; ++ii) {
358 ds >> data;
360 prop.objectDebugId = o.debugId;
361 prop.name = data.name;
362 prop.binding = data.binding;
363 prop.hasNotifySignal = data.hasNotifySignal;
364 prop.valueTypeName = data.valueTypeName;
365 switch (data.type) {
369 {
370 prop.value = data.value;
371 break;
372 }
374 {
376 obj.name = data.value.toString();
377 obj.className = prop.valueTypeName;
379 break;
380 }
382 break;
383 }
384 o.properties << prop;
385 }
386}
387
389 QList<QQmlEngineDebugObjectReference> &o,
390 bool simple)
391{
393 ds >> count;
394 for (qint32 i = 0; i < count; i++) {
396 decode(ds, obj, simple);
397 o << obj;
398 }
399}
400
401QList<QQmlEngineDebugEngineReference> QQmlEngineDebugClient::engines() const
402{
403 Q_D(const QQmlEngineDebugClient);
404 return d->engines;
405}
406
408{
409 Q_D(const QQmlEngineDebugClient);
410 return d->rootContext;
411}
412
414{
415 Q_D(const QQmlEngineDebugClient);
416 return d->object;
417}
418
419QList<QQmlEngineDebugObjectReference> QQmlEngineDebugClient::objects() const
420{
421 Q_D(const QQmlEngineDebugClient);
422 return d->objects;
423}
424
426{
427 Q_D(const QQmlEngineDebugClient);
428 return d->exprResult;
429}
430
432{
433 Q_D(const QQmlEngineDebugClient);
434 return d->valid;
435}
436
439{
440 ds >> c.name >> c.debugId;
441
442 qint32 contextCount;
443 ds >> contextCount;
444
445 for (qint32 ii = 0; ii < contextCount; ++ii) {
446 c.contexts.append(QQmlEngineDebugContextReference());
447 decode(ds, c.contexts.last());
448 }
449
450 qint32 objectCount;
451 ds >> objectCount;
452
453 for (qint32 ii = 0; ii < objectCount; ++ii) {
455 decode(ds, obj, true);
456
457 obj.contextDebugId = c.debugId;
458 c.objects << obj;
459 }
460}
461
463{
465 d->valid = false;
466 QPacket ds(connection()->currentDataStreamVersion(), data);
467
470 ds >> type >> queryId;
471
472 //qDebug() << "QQmlEngineDebugPrivate::message()" << type;
473
474 if (type == "LIST_ENGINES_R") {
476 ds >> count;
477
478 d->engines.clear();
479 for (qint32 ii = 0; ii < count; ++ii) {
481 ds >> eng.name;
482 ds >> eng.debugId;
483 d->engines << eng;
484 }
485 } else if (type == "LIST_OBJECTS_R") {
486 if (!ds.atEnd())
487 decode(ds, d->rootContext);
488
489 } else if (type == "FETCH_OBJECT_R") {
490 if (!ds.atEnd())
491 decode(ds, d->object, false);
492
493 } else if (type == "FETCH_OBJECTS_FOR_LOCATION_R") {
494 if (!ds.atEnd())
495 decode(ds, d->objects, false);
496
497 } else if (type == "EVAL_EXPRESSION_R") {;
498 ds >> d->exprResult;
499
500 } else if (type == "WATCH_PROPERTY_R") {
501 ds >> d->valid;
502
503 } else if (type == "WATCH_OBJECT_R") {
504 ds >> d->valid;
505
506 } else if (type == "WATCH_EXPR_OBJECT_R") {
507 ds >> d->valid;
508
509 } else if (type == "UPDATE_WATCH") {
510 qint32 debugId;
513 ds >> debugId >> name >> value;
515 return;
516
517 } else if (type == "OBJECT_CREATED") {
518 qint32 engineId;
519 qint32 objectId;
520 qint32 parentId;
521 ds >> engineId >> objectId >> parentId;
522 emit newObject(objectId);
523 return;
524 } else if (type == "SET_BINDING_R") {
525 ds >> d->valid;
526 } else if (type == "RESET_BINDING_R") {
527 ds >> d->valid;
528 } else if (type == "SET_METHOD_BODY_R") {
529 ds >> d->valid;
530 } else if (type == "NO_WATCH_R") {
531 ds >> d->valid;
532 }
533 emit result();
534}
535
536
538{
540 return d->nextId++;
541}
542
544
545#include "moc_qqmlenginedebugclient_p.cpp"
\inmodule QtCore
Definition qbytearray.h:57
bool atEnd() const
Returns true if the I/O device has reached the end position (end of the stream or file) or if there i...
The QPacket class encapsulates an unfragmentable packet of data to be transmitted by QPacketProtocol.
Definition qpacket_p.h:24
void clear()
Clears the packet, discarding any data.
Definition qpacket.cpp:96
const QByteArray & data() const
Returns a reference to the raw packet data.
Definition qpacket.cpp:77
QString name() const
void sendMessage(const QByteArray &message)
State state() const
QQmlDebugConnection * connection() const
QQmlEngineDebugClientPrivate(QQmlDebugConnection *connection)
qint32 resetBindingForObject(qint32 objectDebugId, const QString &propertyName, bool *success)
void decode(QPacket &ds, QQmlEngineDebugContextReference &)
qint32 queryObjectsForLocationRecursive(const QString &file, qint32 lineNumber, qint32 columnNumber, bool *success)
qint32 queryExpressionResultBC(qint32 objectDebugId, const QString &expr, bool *success)
QList< QQmlEngineDebugObjectReference > objects() const
qint32 queryExpressionResult(qint32 objectDebugId, const QString &expr, bool *success)
qint32 queryRootContexts(const QQmlEngineDebugEngineReference &, bool *success)
void removeWatch(qint32 watch, bool *success)
QQmlEngineDebugClient(QQmlDebugConnection *conn)
qint32 queryAvailableEngines(bool *success)
void newObject(qint32 objectId)
qint32 setMethodBody(qint32 objectDebugId, const QString &methodName, const QString &methodBody, bool *success)
qint32 addWatch(const QQmlEngineDebugPropertyReference &, bool *success)
qint32 setBindingForObject(qint32 objectDebugId, const QString &propertyName, const QVariant &bindingExpression, bool isLiteralValue, const QString &source, qint32 line, bool *success)
qint32 queryObjectRecursive(const QQmlEngineDebugObjectReference &, bool *success)
QQmlEngineDebugContextReference rootContext() const
void messageReceived(const QByteArray &) override
QQmlEngineDebugObjectReference object() const
void valueChanged(QByteArray, QVariant)
qint32 queryObject(const QQmlEngineDebugObjectReference &, bool *success)
QList< QQmlEngineDebugEngineReference > engines() const
qint32 queryObjectsForLocation(const QString &file, qint32 lineNumber, qint32 columnNumber, bool *success)
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qurl.h:94
\inmodule QtCore
Definition qvariant.h:65
T value() const &
Definition qvariant.h:516
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Definition qvariant.h:536
Combined button and popup list for selecting options.
DBusConnection * connection
static QString methodName(const QDBusIntrospection::Method &method)
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define qWarning
Definition qlogging.h:166
GLuint * queryId
GLenum GLuint id
[7]
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum type
GLenum GLuint GLsizei propCount
GLuint name
GLsizei GLsizei GLchar * source
GLhandleARB obj
[2]
const GLubyte * c
QPacket & operator>>(QPacket &ds, QQmlObjectData &data)
#define emit
int qint32
Definition qtypes.h:49
#define decode(x)
const char property[13]
Definition qwizard.cpp:101
QFile file
[0]
QJSEngine engine
[0]
Definition moc.h:23