summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2024-07-08 18:34:23 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2024-07-09 01:27:33 +0200
commit1df1c0b6fdc40a3cb9e89c4d07adc89c37c7582b (patch)
tree44e22686a2a1d0f279409f322c7b286ed24e3fde
parent6a49e551683c63549e0ba8357c9a66930f40c1fe (diff)
Fix sameLocale() assertions in qlocale.cpp
The assertion is about entries at the same index having matching language, script and territory tags. I forgot that the system locale has its m_index set to match the closest-matching CLDR data table, so might not have the same tags as the locale_data[] entry at its given index. Pick-to: 6.8 Fixes: QTBUG-126390 Change-Id: Icb8cc09cc2a9d66a0af301a300f44923d7400ce9 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r--src/corelib/text/qlocale.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp
index 86ab072b736..25461601fa1 100644
--- a/src/corelib/text/qlocale.cpp
+++ b/src/corelib/text/qlocale.cpp
@@ -3021,6 +3021,9 @@ QString QLocale::standaloneDayName(int day, FormatType type) const
// Only used in assertions
[[maybe_unused]] static bool sameLocale(const QLocaleData *locale, const QCalendarLocale &calendar)
{
+ // NB: pass locale_data[] entry at the same index as the calendar one; this
+ // shall usually be the locale's m_data, but for the system locale it's
+ // different.
return locale->m_language_id == calendar.m_language_id
&& locale->m_script_id == calendar.m_script_id
&& locale->m_territory_id == calendar.m_territory_id;
@@ -3135,7 +3138,7 @@ QString QCalendarBackend::monthName(const QLocale &locale, int month, int,
{
Q_ASSERT(month >= 1 && month <= maximumMonthsInYear());
const QCalendarLocale &monthly = localeMonthIndexData()[locale.d->m_index];
- Q_ASSERT(sameLocale(locale.d->m_data, monthly));
+ Q_ASSERT(sameLocale(&locale_data[locale.d->m_index], monthly));
return rawMonthName(monthly, localeMonthData(), month, format);
}
@@ -3171,7 +3174,7 @@ QString QCalendarBackend::standaloneMonthName(const QLocale &locale, int month,
{
Q_ASSERT(month >= 1 && month <= maximumMonthsInYear());
const QCalendarLocale &monthly = localeMonthIndexData()[locale.d->m_index];
- Q_ASSERT(sameLocale(locale.d->m_data, monthly));
+ Q_ASSERT(sameLocale(&locale_data[locale.d->m_index], monthly));
return rawStandaloneMonthName(monthly, localeMonthData(), month, format);
}