From a1c27748d22f94d608cc499db527bf989a5516f2 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 2 Mar 2017 14:23:05 +0100 Subject: Make QLocale consistent about special handling of the C locale QLocale::matchingLocales() simply created each locale using the basic data, without (unless the matching conditions stipulated Language C) applying number-options hacks that it applies everywhere else, when creating the C locale. Thus the C locale in its returned list (if it wasn't the only entry) ended up with the default number options, without omiting separators in numbers. Thus QLocale::c() didn't actually appear as an entry in the list. Discovered while investigating QTBUG-58947. Added a dumb autotest that checks various ways of getting the C locale do actually give us equal locale objects. Fixed matchingLocales() to apply the same hack as is used elsewhere for the C locale. Change-Id: I263f31da623052b63171f5b5a83c65802383df21 Reviewed-by: Thiago Macieira --- src/corelib/tools/qlocale.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib/tools/qlocale.cpp') diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 2ce410062a..c183224c82 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -2115,8 +2115,8 @@ QList QLocale::matchingLocales(QLocale::Language language, && (language == QLocale::AnyLanguage || data->m_language_id == uint(language))) { if ((script == QLocale::AnyScript || data->m_script_id == uint(script)) && (country == QLocale::AnyCountry || data->m_country_id == uint(country))) { - QLocale locale(*QLocalePrivate::create(data)); - result.append(locale); + result.append(QLocale(*(data->m_language_id == C ? c_private() + : QLocalePrivate::create(data)))); } ++data; } -- cgit v1.2.3