From 6e21c9ac4a70c448b42666b622d6001fefc1c231 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 13 Jan 2019 15:38:30 +0100 Subject: [PATCH] QLocale: fix crash when using qDebug() in a global destructor `kdevelop -s doesnotexist` led to ASSERT failure in Q_GLOBAL_STATIC: "The global static was used after being destroyed because of a qDebug() statement in some "unregister" method called by a global object's destructor. This is normally fine, but with %{time} in QT_MESSAGE_PATTERN, qDebug() ends up using QLocale after its global objects (systemLocalePrivate and defaultLocalePrivate) were destroyed. Change-Id: I8d8b34e0197ad1eda8283fcf36d2c250385bb1a3 Reviewed-by: Thiago Macieira --- src/corelib/tools/qlocale.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 1f5d5f0dc6..63499ab93f 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -2367,6 +2367,8 @@ QLocale QLocale::system() { // this function is NOT thread-safe! QT_PREPEND_NAMESPACE(systemData)(); // trigger updating of the system data if necessary + if (systemLocalePrivate.isDestroyed()) + return QLocale(QLocale::C); return QLocale(*systemLocalePrivate->data()); }