diff options
Diffstat (limited to 'src/qml/debugger/qqmldebug.h')
-rw-r--r-- | src/qml/debugger/qqmldebug.h | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/qml/debugger/qqmldebug.h b/src/qml/debugger/qqmldebug.h index d2a0570423..095670a03b 100644 --- a/src/qml/debugger/qqmldebug.h +++ b/src/qml/debugger/qqmldebug.h @@ -56,7 +56,13 @@ struct Q_QML_EXPORT QQmlDebuggingEnabler WaitForClient }; + static void enableDebugging(bool printWarning); + +#if QT_DEPRECATED_SINCE(6, 4) + QT_DEPRECATED_VERSION_X_6_4("Use QQmlTriviallyDestructibleDebuggingEnabler instead " + "or just call QQmlDebuggingEnabler::enableDebugging().") QQmlDebuggingEnabler(bool printWarning = true); +#endif static QStringList debuggerServices(); static QStringList inspectorServices(); @@ -73,12 +79,23 @@ struct Q_QML_EXPORT QQmlDebuggingEnabler const QVariantHash &configuration = QVariantHash()); }; +// Unnamed namespace to signal the compiler that we +// indeed want each TU to have its own QQmlDebuggingEnabler. +namespace { +struct QQmlTriviallyDestructibleDebuggingEnabler { + QQmlTriviallyDestructibleDebuggingEnabler(bool printWarning = true) + { + static_assert(std::is_trivially_destructible_v<QQmlTriviallyDestructibleDebuggingEnabler>); + QQmlDebuggingEnabler::enableDebugging(printWarning); + } +}; // Execute code in constructor before first QQmlEngine is instantiated #if defined(QT_QML_DEBUG_NO_WARNING) -static QQmlDebuggingEnabler qQmlEnableDebuggingHelper(false); +static QQmlTriviallyDestructibleDebuggingEnabler qQmlEnableDebuggingHelper(false); #elif defined(QT_QML_DEBUG) -static QQmlDebuggingEnabler qQmlEnableDebuggingHelper(true); +static QQmlTriviallyDestructibleDebuggingEnabler qQmlEnableDebuggingHelper(true); #endif +} // unnamed namespace #endif |