diff --git a/src/blackmisc/logcategorylist.h b/src/blackmisc/logcategorylist.h index fa6be1a8a..f195fb4bf 100644 --- a/src/blackmisc/logcategorylist.h +++ b/src/blackmisc/logcategorylist.h @@ -112,15 +112,16 @@ namespace BlackMisc static const CLogCategoryList &fromClass() { static_assert(sizeof(T) > 0, "T must be a complete type, not forward declared"); - static QThreadStorage list; //! \todo C++17: make list an inline static member variable template - if (! list.hasLocalData()) + static const auto list = [] { - list.localData().appendCategoriesFromMemberFunction(tag(), THasGetLogCategories()); - list.localData().appendCategoriesFromMetaType(tag(), std::integral_constant::Defined>()); - list.localData().appendCategoriesFromMetaObject(tag(), std::is_base_of()); - if (list.localData().isEmpty()) { list.localData().push_back(CLogCategory::uncategorized()); } - } - return list.localData(); + CLogCategoryList list; + list.appendCategoriesFromMemberFunction(tag(), THasGetLogCategories()); + list.appendCategoriesFromMetaType(tag(), std::integral_constant::Defined>()); + list.appendCategoriesFromMetaObject(tag(), std::is_base_of()); + if (list.isEmpty()) { list.push_back(CLogCategory::uncategorized()); } + return list; + }(); + return list; } template