diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-05-27 10:21:14 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-06-02 00:42:51 +0000 |
commit | 7bfbd706b56c426e2683e519543b56426310520f (patch) | |
tree | 37e64901634cf65cd988be2f511c87bf2a8824b3 /src/qml/debugger/qqmldebug.h | |
parent | 130eafa75bed2c4f0c72e2f4e4402b86837e153f (diff) |
qqmldebug.h: Wrap the QML debugging enabler into an unnamed namespace
This way compilers will hopefully not complain about the use of global
constructors anymore. It's clear now that we want a separate
QQmlDebuggingEnabler for each CU.
Change-Id: Ief8e748a87612c04a8ca9a8535f10d905675b918
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
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 |