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
4#ifndef QQMLDEBUG_H
5#define QQMLDEBUG_H
6
7#include <QtQml/qtqmlglobal.h>
8#include <QtCore/qstring.h>
9#include <QtCore/qvariant.h>
10#include <QtCore/qhash.h> // QVariantHash
11
12QT_BEGIN_NAMESPACE
13
14#if QT_CONFIG(qml_debug)
15
16struct Q_QML_EXPORT QQmlDebuggingEnabler
17{
18 enum StartMode {
19 DoNotWaitForClient,
20 WaitForClient
21 };
22
23 static void enableDebugging(bool printWarning);
24
25#if QT_DEPRECATED_SINCE(6, 4)
26 QT_DEPRECATED_VERSION_X_6_4("Use QQmlTriviallyDestructibleDebuggingEnabler instead "
27 "or just call QQmlDebuggingEnabler::enableDebugging().")
28 QQmlDebuggingEnabler(bool printWarning = true);
29#endif
30
31 static QStringList debuggerServices();
32 static QStringList inspectorServices();
33 static QStringList profilerServices();
34 static QStringList nativeDebuggerServices();
35
36 static void setServices(const QStringList &services);
37
38 static bool startTcpDebugServer(int port, StartMode mode = DoNotWaitForClient,
39 const QString &hostName = QString());
40 static bool connectToLocalDebugger(const QString &socketFileName,
41 StartMode mode = DoNotWaitForClient);
42 static bool startDebugConnector(const QString &pluginName,
43 const QVariantHash &configuration = QVariantHash());
44};
45
46// Unnamed namespace to signal the compiler that we
47// indeed want each TU to have its own QQmlDebuggingEnabler.
48namespace {
49struct QQmlTriviallyDestructibleDebuggingEnabler {
50 QQmlTriviallyDestructibleDebuggingEnabler(bool printWarning = true)
51 {
52 static_assert(std::is_trivially_destructible_v<QQmlTriviallyDestructibleDebuggingEnabler>);
53 QQmlDebuggingEnabler::enableDebugging(printWarning);
54 }
55};
56// Execute code in constructor before first QQmlEngine is instantiated
57#if defined(QT_QML_DEBUG_NO_WARNING)
58static QQmlTriviallyDestructibleDebuggingEnabler qQmlEnableDebuggingHelper(false);
59#elif defined(QT_QML_DEBUG)
60static QQmlTriviallyDestructibleDebuggingEnabler qQmlEnableDebuggingHelper(true);
61#endif
62} // unnamed namespace
63
64#endif
65
66QT_END_NAMESPACE
67
68#endif // QQMLDEBUG_H
69

source code of qtdeclarative/src/qml/debugger/qqmldebug.h