X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/968b44d37b9fcdc5232fb68312a65e4fc6b5f4ab..2e6bfeb9035233b2889af03f7846d2c77125efb7:/src/common/intl.cpp?ds=sidebyside diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 5d7cb3e38d..16bdbd4563 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -206,7 +206,11 @@ wxLanguageInfoArray *wxLocale::ms_languagesDB = NULL; 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); @@ -285,13 +289,7 @@ bool wxLocale::DoInit(const wxString& name, 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); } @@ -1444,10 +1442,10 @@ wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory cat) // 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