From b2871765ced8059e571d17d4010e8d8ada4e9190 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 31 May 2021 15:46:41 +0200 Subject: Fix augmentation of UI language list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/corelib/text/qlocale.cpp | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) (limited to 'src/corelib/text/qlocale.cpp') 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. -- cgit v1.2.3