fix for a crash in ~wxLocale and incorrect GetLanguage() return value (patch 729758)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20413 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -614,7 +614,8 @@ bool wxLocale::Init(const wxChar *szName,
|
|||||||
|
|
||||||
wxCHECK_MSG( szLocale, FALSE, _T("no locale to set in wxLocale::Init()") );
|
wxCHECK_MSG( szLocale, FALSE, _T("no locale to set in wxLocale::Init()") );
|
||||||
}
|
}
|
||||||
m_pszOldLocale = wxSetlocale(LC_ALL, szLocale);
|
|
||||||
|
m_pszOldLocale = wxStrdup(wxSetlocale(LC_ALL, szLocale));
|
||||||
if ( m_pszOldLocale == NULL )
|
if ( m_pszOldLocale == NULL )
|
||||||
wxLogError(_("locale '%s' can not be set."), szLocale);
|
wxLogError(_("locale '%s' can not be set."), szLocale);
|
||||||
|
|
||||||
@@ -803,12 +804,15 @@ bool wxLocale::Init(int language, int flags)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WX_NO_LOCALE_SUPPORT
|
#ifndef WX_NO_LOCALE_SUPPORT
|
||||||
wxChar *szLocale = retloc ? wxStrdup(retloc) : NULL;
|
wxChar *szLocale = retloc ? wxStrdup(retloc) : NULL;
|
||||||
bool ret = Init(name, canonical, retloc,
|
bool ret = Init(name, canonical, retloc,
|
||||||
(flags & wxLOCALE_LOAD_DEFAULT) != 0,
|
(flags & wxLOCALE_LOAD_DEFAULT) != 0,
|
||||||
(flags & wxLOCALE_CONV_ENCODING) != 0);
|
(flags & wxLOCALE_CONV_ENCODING) != 0);
|
||||||
if (szLocale)
|
free(szLocale);
|
||||||
free(szLocale);
|
|
||||||
|
if ( ret )
|
||||||
|
m_language = lang;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1499,6 +1503,7 @@ wxLocale::~wxLocale()
|
|||||||
// restore old locale
|
// restore old locale
|
||||||
wxSetLocale(m_pOldLocale);
|
wxSetLocale(m_pOldLocale);
|
||||||
wxSetlocale(LC_ALL, m_pszOldLocale);
|
wxSetlocale(LC_ALL, m_pszOldLocale);
|
||||||
|
free((wxChar *)m_pszOldLocale); // const_cast
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the translation of given string in current locale
|
// get the translation of given string in current locale
|
||||||
|
Reference in New Issue
Block a user