From 94de5f9b25e1816039885c765e2a5b312f7daa7e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 30 Jul 2021 12:38:20 -0700 Subject: QString::localeAwareCompare: adapt to QLocale::setDefault() being called Because we're using a thread-specific global static, we need to recreate the QCollator type every time setDefault() is called. Since one is stored per-thread, we simply increment a generational counter and check that the next time that QString::localeAwareCompare is called in each thread. The issue was introduced on f6425da424b1a0d5927ee56fa657a9b31ca5afd1 (5.12) even though we were supposed to be using QCollator since commit 5279134935e858e6fa8565c936b17e88d7bded50 (5.3). Fixes: QTBUG-95050 Pick-to: 6.2 Change-Id: I7e0b82c2d2fe464082d8fffd1696a8c9f74e5b30 Reviewed-by: Lars Knoll --- src/corelib/text/qlocale.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib/text/qlocale.cpp') diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index d5cde8a69d..ca4f7733f3 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -780,9 +780,9 @@ QDataStream &operator>>(QDataStream &ds, QLocale &l) } #endif // QT_NO_DATASTREAM - static const int locale_data_size = sizeof(locale_data)/sizeof(QLocaleData) - 1; +QBasicAtomicInt QLocalePrivate::s_generation = Q_BASIC_ATOMIC_INITIALIZER(0); Q_GLOBAL_STATIC_WITH_ARGS(QSharedDataPointer, defaultLocalePrivate, (new QLocalePrivate(defaultData(), defaultIndex()))) @@ -1206,6 +1206,7 @@ void QLocale::setDefault(const QLocale &locale) // update the cached private *defaultLocalePrivate = locale.d; + QLocalePrivate::s_generation.fetchAndAddRelaxed(1); } /*! -- cgit v1.2.3