void wxLocale::DoCommonInit()
{
- m_pszOldLocale = NULL;
+ // Store the current locale in order to be able to restore it in the dtor.
+ m_pszOldLocale = wxSetlocale(LC_ALL, NULL);
+ if ( m_pszOldLocale )
+ m_pszOldLocale = wxStrdup(m_pszOldLocale);
+
m_pOldLocale = wxSetLocale(this);
wxS("no locale to set in wxLocale::Init()") );
}
- const char *oldLocale = wxSetlocale(LC_ALL, szLocale);
- if ( oldLocale )
- m_pszOldLocale = wxStrdup(oldLocale);
- else
- m_pszOldLocale = NULL;
-
- if ( m_pszOldLocale == NULL )
+ if ( !wxSetlocale(LC_ALL, szLocale) )
{
wxLogError(_("locale '%s' cannot be set."), szLocale);
}
// this were not the case.
wxASSERT_MSG( strcmp(setlocale(LC_ALL, NULL), "C") == 0,
wxS("You probably called setlocale() directly instead ")
- wxS("of calling wxSetLocale() and now there is a ")
+ wxS("of using wxLocale and now there is a ")
wxS("mismatch between C/C++ and Windows locale.\n")
- wxS("Things are going to break, use wxSetLocale() to ")
- wxS("avoid this!") );
+ wxS("Things are going to break, please only change ")
+ wxS("locale by creating wxLocale objects to avoid this!") );
// Return the hard coded values for C locale. This is really the right