summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qlocale.cpp
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2021-05-31 15:46:41 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2021-06-07 17:14:14 +0200
commitb2871765ced8059e571d17d4010e8d8ada4e9190 (patch)
tree4bb38ba470616233ceb05d9d6df03f638b41fa50 /src/corelib/text/qlocale.cpp
parent68297195759492594ac4143b7f208e17fe6f594b (diff)
Fix augmentation of UI language list
Previously, the augmentation wasn't being applied to the system locale, due to a mistaken test claiming the locale's name didn't resemble the string from which it was constructed. The test dates from before various fixes to likely sub-tag processing that should make it redundant now. This makes QLocalePrivate::rawName() also redundant (and its conversion of QLatin1String to QByteArray relied on '\0' termination which wasn't actually present in the various codes). Expanded the test of systemLocale() to also test uiLanguages() turns a single entry into the list we expect; and add two new test-cases. (The test uses a mock system locale class, making this independent of the platform backend.) Fixes: QTBUG-92234 Pick-to: 6.1 5.15 Change-Id: I0cdf6eae152a42dc377f4ea3e62c282ff4be1764 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/text/qlocale.cpp')
-rw-r--r--src/corelib/text/qlocale.cpp25
1 files changed, 2 insertions, 23 deletions
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp
index 74eff267e3..47fb6dcb9d 100644
--- a/src/corelib/text/qlocale.cpp
+++ b/src/corelib/text/qlocale.cpp
@@ -407,22 +407,6 @@ QByteArray QLocalePrivate::bcp47Name(char separator) const
return m_data->id().withLikelySubtagsRemoved().name(separator);
}
-/*!
- \internal
- */
-QByteArray QLocalePrivate::rawName(char separator) const
-{
- QByteArrayList parts;
- if (m_data->m_language_id != QLocale::AnyLanguage)
- parts.append(languageCode().latin1());
- if (m_data->m_script_id != QLocale::AnyScript)
- parts.append(scriptCode().latin1());
- if (m_data->m_territory_id != QLocale::AnyTerritory)
- parts.append(territoryCode().latin1());
-
- return parts.join(separator);
-}
-
static int findLocaleIndexById(const QLocaleId &localeId)
{
quint16 idx = locale_index[localeId.language_id];
@@ -4291,13 +4275,8 @@ QStringList QLocale::uiLanguages() const
if (i < uiLanguages.size()) {
// Adding likely-adjusted forms to system locale's list.
// Name the locale is derived from:
- const QString &name = uiLanguages.at(i);
- prior = name.toLatin1();
- // Don't try to likely-adjust if construction's likely-adjustments
- // were so drastic the result doesn't match the prior name:
- if (locale.name() != name && locale.d->rawName() != prior)
- continue;
- // Insert just after prior:
+ prior = uiLanguages.at(i).toLatin1();
+ // Insert just after the entry we're supplementing:
j = i + 1;
} else {
// Plain locale, not system locale; just append.