Fix wxLocale::IsOk() in case of initialization failure
Ever since 700256bbdb
IsOk() returned true even
if setting the locale actually failed because the old locale was still set to
the null value.
Apply the minimal possible fix for this and just reset the old locale pointer
to null if initializing the locale fails to make sure IsOk() doesn't return
true in this case.
This commit is contained in:
@@ -540,6 +540,11 @@ bool wxLocale::Init(int language, int flags)
|
||||
{
|
||||
wxLogWarning(_("Cannot set locale to language \"%s\"."), name.c_str());
|
||||
|
||||
// As we failed to change locale, there is no need to restore the
|
||||
// previous one: it's still valid.
|
||||
free(const_cast<char *>(m_pszOldLocale));
|
||||
m_pszOldLocale = NULL;
|
||||
|
||||
// continue nevertheless and try to load at least the translations for
|
||||
// this language
|
||||
}
|
||||
@@ -1034,9 +1039,12 @@ wxLocale::~wxLocale()
|
||||
// restore old locale pointer
|
||||
wxSetLocale(m_pOldLocale);
|
||||
|
||||
if ( m_pszOldLocale )
|
||||
{
|
||||
wxSetlocale(LC_ALL, m_pszOldLocale);
|
||||
free(const_cast<char *>(m_pszOldLocale));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// check if the given locale is provided by OS and C run time
|
||||
|
Reference in New Issue
Block a user