From c657bb7b51115d6e1719166fb502bb0ca1dcf4e8 Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Wed, 9 Oct 2013 13:06:01 +0200 Subject: 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 Reviewed-by: Kai Koehne --- src/corelib/global/qlogging.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/corelib/global') 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 -- cgit v1.2.3