don't change locale in XRC GetFloat() method, change the strings to use the current locale decimal point separator instead (patch 1783849)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@48620 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-09-09 22:24:43 +00:00
parent 97fee60f06
commit 2e90607dbe

View File

@@ -968,20 +968,18 @@ long wxXmlResourceHandler::GetLong(const wxString& param, long defaultv)
float wxXmlResourceHandler::GetFloat(const wxString& param, float defaultv)
{
wxString str = GetParamValue(param);
// strings in XRC always use C locale but wxString::ToDouble() uses the
// current one, so transform the string to it supposing that the only
// difference between them is the decimal separator
str.Replace(wxT("."), wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT,
wxLOCALE_CAT_NUMBER));
double value;
wxString str1 = GetParamValue(param);
#ifndef __WXWINCE__
const char *prevlocale = setlocale(LC_NUMERIC, "C");
#endif
if (!str1.ToDouble(&value))
if (!str.ToDouble(&value))
value = defaultv;
#ifndef __WXWINCE__
setlocale(LC_NUMERIC, prevlocale);
#endif
return wx_truncate_cast(float, value);
}