Merge branch 'msw-fix-decimal-point' of https://github.com/vslavik/wxWidgets

Fix decimal point assertions with unknown Win32 locales.

See https://github.com/wxWidgets/wxWidgets/pull/2330
This commit is contained in:
Vadim Zeitlin
2021-04-18 02:10:51 +02:00
2 changed files with 14 additions and 5 deletions

View File

@@ -363,6 +363,9 @@ private:
const char *m_pszOldLocale; // previous locale from setlocale() const char *m_pszOldLocale; // previous locale from setlocale()
wxLocale *m_pOldLocale; // previous wxLocale wxLocale *m_pOldLocale; // previous wxLocale
#ifdef __WIN32__
wxUint32 m_oldLCID;
#endif
bool m_initialized; bool m_initialized;

View File

@@ -253,6 +253,9 @@ void wxLocale::DoCommonInit()
if ( m_pszOldLocale ) if ( m_pszOldLocale )
m_pszOldLocale = wxStrdup(m_pszOldLocale); m_pszOldLocale = wxStrdup(m_pszOldLocale);
#ifdef __WIN32__
m_oldLCID = ::GetThreadLocale();
#endif
m_pOldLocale = wxSetLocale(this); m_pOldLocale = wxSetLocale(this);
@@ -1098,6 +1101,11 @@ wxLocale::~wxLocale()
wxSetlocale(LC_ALL, m_pszOldLocale); wxSetlocale(LC_ALL, m_pszOldLocale);
free(const_cast<char *>(m_pszOldLocale)); free(const_cast<char *>(m_pszOldLocale));
} }
#ifdef __WIN32__
::SetThreadLocale(m_oldLCID);
wxMSWSetThreadUILanguage(LANGIDFROMLCID(m_oldLCID));
#endif
} }
@@ -1688,10 +1696,7 @@ GetInfoFromLCID(LCID lcid,
/* static */ /* static */
wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory cat) wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory cat)
{ {
const wxLanguageInfo * const if ( !wxGetLocale() )
info = wxGetLocale() ? GetLanguageInfo(wxGetLocale()->GetLanguage())
: NULL;
if ( !info )
{ {
// wxSetLocale() hadn't been called yet of failed, hence CRT must be // wxSetLocale() hadn't been called yet of failed, hence CRT must be
// using "C" locale -- but check it to detect bugs that would happen if // using "C" locale -- but check it to detect bugs that would happen if
@@ -1734,7 +1739,8 @@ wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory cat)
} }
} }
return GetInfoFromLCID(info->GetLCID(), index, cat); // wxSetLocale() succeeded and so thread locale was set together with CRT one.
return GetInfoFromLCID(::GetThreadLocale(), index, cat);
} }
/* static */ /* static */