summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qlogging.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2025-02-08 14:33:27 -0800
committerThiago Macieira <thiago.macieira@intel.com>2025-03-31 17:04:13 -0400
commit4afd089612448ae13136e287ced134c71499cfec (patch)
tree0215f40365e84069243c55547fdf78508c3c148b /src/corelib/global/qlogging.cpp
parent51c8c0695192677f821759b98f8ba6496df41fa7 (diff)
QLoggingCategory: make defaultCategory() truly a global static
We don't need two independent Q_GLOBAL_STATIC variables: one for the default category and the other for the logging registry. We can simply save one in the other. However, we can do better than even that. QLoggingCategory currently doesn't hold any allocated resources: the const char *name points to a static string and the void *d is always null. That means the constructor and destructor only serve to register and unregister the category with QLoggingRegistry, so we transfer that responsibility to QLoggingRegistry itself (the un-registering is implicit in the registry's own destruction). The benefit of this is that the default QLoggingCategory can never be found in a destroyed state, however late user code may be running after ::exit() was called. We have had a number of these issues of De-Initialization Order Fiasco, especially since the changes to QThreadData destruction timing. Pick-to: 6.9 Change-Id: I2b6ea597ac257837669afffde2684c7b44a42e92 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/global/qlogging.cpp')
-rw-r--r--src/corelib/global/qlogging.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 12d9422daad..97c7e70e386 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -953,7 +953,7 @@ QDebug QMessageLogger::fatal(QMessageLogger::CategoryFunction catFunc) const
static bool isDefaultCategory(const char *category)
{
- return !category || strcmp(category, "default") == 0;
+ return !category || strcmp(category, QLoggingRegistry::defaultCategoryName) == 0;
}
/*!