mirror of https://github.com/nymea/nymea.git
Fix initialisation of the global logging category variable
Just accessing the raw variable doesn't guarantee the order of construction and may lead to crashes in certain constellations.pull/370/head
parent
a11a219bbf
commit
f1fa59c535
|
|
@ -601,7 +601,7 @@ QStringList NymeaCore::getAvailableLanguages()
|
|||
|
||||
QStringList NymeaCore::loggingFilters()
|
||||
{
|
||||
return s_nymeaLoggingCategories;
|
||||
return nymeaLoggingCategories();
|
||||
}
|
||||
|
||||
QStringList NymeaCore::loggingFiltersPlugins()
|
||||
|
|
|
|||
|
|
@ -100,6 +100,9 @@
|
|||
/*! IntegrationPlugin constructor. IntegrationPlugins will be instantiated by the system.
|
||||
This should never be called manually by a plugin implementation.
|
||||
*/
|
||||
|
||||
NYMEA_LOGGING_CATEGORY(dcIntegrations, "Integrations")
|
||||
|
||||
IntegrationPlugin::IntegrationPlugin(QObject *parent):
|
||||
QObject(parent)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,10 +34,12 @@
|
|||
#include <QDateTime>
|
||||
#include <QMutex>
|
||||
|
||||
QStringList s_nymeaLoggingCategories;
|
||||
QStringList& nymeaLoggingCategories() {
|
||||
static QStringList _nymeaLoggingCategories;
|
||||
return _nymeaLoggingCategories;
|
||||
}
|
||||
|
||||
// FIXME: Those should eventually disappear from here
|
||||
NYMEA_LOGGING_CATEGORY(dcIntegrations, "Integrations");
|
||||
NYMEA_LOGGING_CATEGORY(dcThing, "Thing")
|
||||
NYMEA_LOGGING_CATEGORY(dcThingManager, "ThingManager")
|
||||
NYMEA_LOGGING_CATEGORY(dcSystem, "System")
|
||||
|
|
|
|||
|
|
@ -34,13 +34,12 @@
|
|||
#include <QLoggingCategory>
|
||||
#include <QDebug>
|
||||
|
||||
extern QStringList s_nymeaLoggingCategories;
|
||||
|
||||
QStringList& nymeaLoggingCategories();
|
||||
|
||||
#define NYMEA_LOGGING_CATEGORY(name, string) \
|
||||
class NymeaLoggingCategory##name: public QLoggingCategory { \
|
||||
public: \
|
||||
NymeaLoggingCategory##name(): QLoggingCategory(string) { s_nymeaLoggingCategories.append(string); } \
|
||||
NymeaLoggingCategory##name(): QLoggingCategory(string) { nymeaLoggingCategories().append(string); } \
|
||||
}; \
|
||||
static NymeaLoggingCategory##name s_##name; \
|
||||
const QLoggingCategory &name() \
|
||||
|
|
|
|||
Loading…
Reference in New Issue