1// Copyright (C) 2017 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
4#include "qqmldebugmessageclient_p.h"
5
6#include <QtCore/qdatastream.h>
7
8QT_BEGIN_NAMESPACE
9
10/*!
11 \class QQmlDebugMessageClient
12 \internal
13
14 \brief Client for the debug message service
15
16 The QQmlDebugMessageClient receives debug messages routed through the QML
17 debug connection via QDebugMessageService.
18 */
19
20QQmlDebugMessageClient::QQmlDebugMessageClient(QQmlDebugConnection *client)
21 : QQmlDebugClient(QLatin1String("DebugMessages"), client)
22{
23}
24
25void QQmlDebugMessageClient::messageReceived(const QByteArray &data)
26{
27 QDataStream ds(data);
28 QByteArray command;
29 ds >> command;
30
31 if (command == "MESSAGE") {
32 int type;
33 int line;
34 QByteArray debugMessage;
35 QByteArray file;
36 QByteArray function;
37 ds >> type >> debugMessage >> file >> line >> function;
38 QQmlDebugContextInfo info;
39 info.line = line;
40 info.file = QString::fromUtf8(ba: file);
41 info.function = QString::fromUtf8(ba: function);
42 info.timestamp = -1;
43 if (!ds.atEnd()) {
44 QByteArray category;
45 ds >> category;
46 info.category = QString::fromUtf8(ba: category);
47 if (!ds.atEnd())
48 ds >> info.timestamp;
49 }
50 emit message(QtMsgType(type), QString::fromUtf8(ba: debugMessage), info);
51 }
52}
53
54QT_END_NAMESPACE
55
56#include "moc_qqmldebugmessageclient_p.cpp"
57

source code of qtdeclarative/src/qmldebug/qqmldebugmessageclient.cpp