diff options
author | Juha Vuolle <juha.vuolle@insta.fi> | 2021-08-17 14:03:08 +0300 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-08-18 16:11:44 +0000 |
commit | 261af4a20cb06aac4215b2d8348c54ac8a34c007 (patch) | |
tree | 6c25927c9871fd482fe61057911f9a0b2784cd9b | |
parent | 5579d436e7daf7126502827f5b7bcf9017ba858d (diff) |
Fix potential initialization order problem
The logging category is now declared as a function (see the macro
definition) rather than as a plain static, which should prevent
potential initialization order issues.
Task-number: QTBUG-68383
Change-Id: Ib71fd7a3840b2dda186c2a06205d781acc389135
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
(cherry picked from commit 63fe6819c79c835adf652f8dd99fda54f6d35cdc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/sensors/qsensormanager.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/sensors/qsensormanager.cpp b/src/sensors/qsensormanager.cpp index 95d9b6c0..d6dcb45c 100644 --- a/src/sensors/qsensormanager.cpp +++ b/src/sensors/qsensormanager.cpp @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE typedef QHash<QByteArray,QSensorBackendFactory*> FactoryForIdentifierMap; typedef QHash<QByteArray,FactoryForIdentifierMap> BackendIdentifiersForTypeMap; -static QLoggingCategory sensorsCategory("qt.sensors"); +Q_LOGGING_CATEGORY(lcSensorManager, "qt.sensors"); class QSensorManagerPrivate : public QObject { @@ -103,14 +103,14 @@ public: break; } #endif - qCDebug(sensorsCategory) << "Loading config from" << config; + qCDebug(lcSensorManager) << "Loading config from" << config; if (!QFile::exists(config)) { - qCDebug(sensorsCategory) << "There is no config file" << config; + qCDebug(lcSensorManager) << "There is no config file" << config; return; } QFile cfgfile(config); if (!cfgfile.open(QFile::ReadOnly)) { - qCWarning(sensorsCategory) << "Can't open config file" << config; + qCWarning(lcSensorManager) << "Can't open config file" << config; return; } @@ -177,9 +177,9 @@ Q_GLOBAL_STATIC(QSensorManagerPrivate, sensorManagerPrivate) static void initPlugin(QObject *o, bool warnOnFail = true) { - qCDebug(sensorsCategory) << "Init plugin" << o; + qCDebug(lcSensorManager) << "Init plugin" << o; if (!o) { - qCWarning(sensorsCategory) << "Null plugin" << o; + qCWarning(lcSensorManager) << "Null plugin" << o; return; } @@ -187,7 +187,7 @@ static void initPlugin(QObject *o, bool warnOnFail = true) if (!d) return; // hardly likely but just in case... if (d->seenPlugins.contains(o)) { - qCDebug(sensorsCategory) << "Plugin is seen" << o; + qCDebug(lcSensorManager) << "Plugin is seen" << o; return; } @@ -198,11 +198,11 @@ static void initPlugin(QObject *o, bool warnOnFail = true) QSensorPluginInterface *plugin = qobject_cast<QSensorPluginInterface*>(o); if (plugin) { - qCDebug(sensorsCategory) << "Register sensors for " << plugin; + qCDebug(lcSensorManager) << "Register sensors for " << plugin; d->seenPlugins.insert(o); plugin->registerSensors(); } else if (warnOnFail) { - qCWarning(sensorsCategory) << "Can't cast to plugin" << o; + qCWarning(lcSensorManager) << "Can't cast to plugin" << o; } } |