Assert consistency between locale and calendar data
They're indexed by the same key and should have the same language, script and country. Just to be sure, assert that. Change-Id: I9d4d9c0ef7078d6dcbb6ceccafdfaff671737689 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
f20be43b82
commit
a472362f36
|
|
@ -3018,6 +3018,14 @@ QString QLocale::standaloneDayName(int day, FormatType type) const
|
|||
|
||||
// Calendar look-up of month and day names:
|
||||
|
||||
// Only used in assertions
|
||||
[[maybe_unused]] static bool sameLocale(const QLocaleData *locale, const QCalendarLocale &calendar)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
|
|
@ -3126,8 +3134,9 @@ QString QCalendarBackend::monthName(const QLocale &locale, int month, int,
|
|||
QLocale::FormatType format) const
|
||||
{
|
||||
Q_ASSERT(month >= 1 && month <= maximumMonthsInYear());
|
||||
return rawMonthName(localeMonthIndexData()[locale.d->m_index],
|
||||
localeMonthData(), month, format);
|
||||
const QCalendarLocale &monthly = localeMonthIndexData()[locale.d->m_index];
|
||||
Q_ASSERT(sameLocale(locale.d->m_data, monthly));
|
||||
return rawMonthName(monthly, localeMonthData(), month, format);
|
||||
}
|
||||
|
||||
QString QRomanCalendar::monthName(const QLocale &locale, int month, int year,
|
||||
|
|
@ -3161,8 +3170,9 @@ QString QCalendarBackend::standaloneMonthName(const QLocale &locale, int month,
|
|||
QLocale::FormatType format) const
|
||||
{
|
||||
Q_ASSERT(month >= 1 && month <= maximumMonthsInYear());
|
||||
return rawStandaloneMonthName(localeMonthIndexData()[locale.d->m_index],
|
||||
localeMonthData(), month, format);
|
||||
const QCalendarLocale &monthly = localeMonthIndexData()[locale.d->m_index];
|
||||
Q_ASSERT(sameLocale(locale.d->m_data, monthly));
|
||||
return rawStandaloneMonthName(monthly, localeMonthData(), month, format);
|
||||
}
|
||||
|
||||
QString QRomanCalendar::standaloneMonthName(const QLocale &locale, int month, int year,
|
||||
|
|
|
|||
Loading…
Reference in New Issue