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
qdebugmessageservice.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
6#include <private/qqmldebugconnector_p.h>
7#include <private/qversionedpacket_p.h>
8
10
11using QQmlDebugPacket = QVersionedPacket<QQmlDebugConnector>;
12
14 const QString &buf)
15{
16 QQmlDebugConnector::service<QDebugMessageServiceImpl>()->sendDebugMessage(type, ctxt, buf);
17}
18
20 QDebugMessageService(2, parent), oldMsgHandler(nullptr),
21 prevState(QQmlDebugService::NotConnected)
22{
23 // don't execute stateChanged() in parallel
24 QMutexLocker lock(&initMutex);
25 timer.start();
26 if (state() == Enabled) {
28 prevState = Enabled;
29 }
30}
31
33 const QMessageLogContext &ctxt,
34 const QString &buf)
35{
36 //We do not want to alter the message handling mechanism
37 //We just eavesdrop and forward the messages to a port
38 //only if a client is connected to it.
40 ws << QByteArray("MESSAGE") << int(type) << buf.toUtf8();
41 ws << QByteArray(ctxt.file) << ctxt.line << QByteArray(ctxt.function);
42 ws << QByteArray(ctxt.category) << timer.nsecsElapsed();
43
44 emit messageToClient(name(), ws.data());
45 if (oldMsgHandler)
46 (*oldMsgHandler)(type, ctxt, buf);
47}
48
50{
51 QMutexLocker lock(&initMutex);
52
53 if (state != Enabled && prevState == Enabled) {
54 QtMessageHandler handler = qInstallMessageHandler(oldMsgHandler);
55 // has our handler been overwritten in between?
56 if (handler != DebugMessageHandler)
58
59 } else if (state == Enabled && prevState != Enabled) {
61 }
62
63 prevState = state;
64}
65
67{
68 QMutexLocker lock(&initMutex);
69 timer = otherTimer;
70}
71
73
74#include "moc_qdebugmessageservice.cpp"
void synchronizeTime(const QElapsedTimer &otherTimer) override
void sendDebugMessage(QtMsgType type, const QMessageLogContext &ctxt, const QString &buf)
QDebugMessageServiceImpl(QObject *parent=nullptr)
void stateChanged(State) override
\inmodule QtCore
void start() noexcept
\typealias QElapsedTimer::Duration Synonym for std::chrono::nanoseconds.
qint64 nsecsElapsed() const noexcept
\inmodule QtCore
Definition qlogging.h:42
const char * category
Definition qlogging.h:54
const char * function
Definition qlogging.h:53
const char * file
Definition qlogging.h:52
\inmodule QtCore
Definition qmutex.h:313
\inmodule QtCore
Definition qobject.h:103
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
else opt state
[0]
QtMessageHandler qInstallMessageHandler(QtMessageHandler h)
Combined button and popup list for selecting options.
void DebugMessageHandler(QtMsgType type, const QMessageLogContext &ctxt, const QString &buf)
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
QtMsgType
Definition qlogging.h:29
void(* QtMessageHandler)(QtMsgType, const QMessageLogContext &, const QString &)
Definition qlogging.h:191
GLenum type
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint name
#define emit
QObject::connect nullptr
QReadWriteLock lock
[0]