summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
authorKevin Ottens <ervin@kde.org>2013-10-09 13:06:01 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-10 09:37:33 +0200
commitc657bb7b51115d6e1719166fb502bb0ca1dcf4e8 (patch)
tree0ea8f7d5bdb6fde5a6931f995af2028280caa673 /src/corelib/global
parent5466eb289f96f9dc9e16604ebddd07a4767254db (diff)
Make sure QLoggingCategory default is available
This avoids crashes in case where qWarning() would be called from a global static deleted after the one holding the default category. I encountered this case with a QLockFile locked from a global static while the application quits, it was calling qAppName which was triggering a qWarning as the qapplication object was gone too. Change-Id: I8910e8559d063e8f0a737bae3da5edc481ab84d3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/qlogging.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 694935b326..063e94069f 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -927,8 +927,10 @@ static void qt_message_print(QtMsgType msgType, const QMessageLogContext &contex
#ifndef QT_BOOTSTRAPPED
// qDebug, qWarning, ... macros do not check whether category is enabled
if (!context.category || (strcmp(context.category, "default") == 0)) {
- if (!QLoggingCategory::defaultCategory().isEnabled(msgType))
- return;
+ if (QLoggingCategory *defaultCategory = &QLoggingCategory::defaultCategory()) {
+ if (!defaultCategory->isEnabled(msgType))
+ return;
+ }
}
#endif