summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2019-01-13 15:38:30 +0100
committerDavid Faure <david.faure@kdab.com>2019-01-13 20:08:48 +0000
commit6e21c9ac4a70c448b42666b622d6001fefc1c231 (patch)
treefd75dd0dcf45fec6c3e114d65a88724a21c99ad5
parent7044409c878f100c005b76fc90717b4f71667f04 (diff)
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 <thiago.macieira@intel.com>
-rw-r--r--src/corelib/tools/qlocale.cpp2
1 files changed, 2 insertions, 0 deletions
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());
}