Check that locale ID argument of wxUILocale ctor is not empty

Disallow using empty wxLocaleIdent here, GetDefault() can, and should,
be used for the user default locale.
This commit is contained in:
Vadim Zeitlin
2021-09-04 20:30:31 +02:00
parent be01b0c36a
commit a47a885718
2 changed files with 9 additions and 1 deletions

View File

@@ -109,7 +109,8 @@ public:
see wxLocaleIdent description for more details.
If @a localeId is not recognized or not supported, default ("C") locale
is used instead.
is used instead. Additionally, if @a localeId is empty (see
wxLocaleIdent::IsEmpty()), an assertion failure is triggered.
*/
explicit wxUILocale(const wxLocaleIdent& localeId);

View File

@@ -158,6 +158,13 @@ const wxUILocale& wxUILocale::GetCurrent()
wxUILocale::wxUILocale(const wxLocaleIdent& localeId)
{
if ( localeId.IsEmpty() )
{
wxFAIL_MSG( "Locale identifier must be initialized" );
m_impl = NULL;
return;
}
m_impl = wxUILocaleImpl::CreateForLocale(localeId);
}