Fix wxLanguageInfo::GetLocaleName()
This function could (and did) return completely wrong results because the value of the pointer returned by setlocale() could be (and was) changed by the subsequent call to setlocale() with different arguments. Fix the problem by copying the returned value into wxString immediately, without any intervening setlocale() calls.
This commit is contained in:
@@ -208,12 +208,17 @@ wxString wxLanguageInfo::GetLocaleName() const
|
|||||||
const char* const orig = wxSetlocale(LC_ALL, NULL);
|
const char* const orig = wxSetlocale(LC_ALL, NULL);
|
||||||
|
|
||||||
const char* const ret = TrySetLocale();
|
const char* const ret = TrySetLocale();
|
||||||
if ( !ret )
|
wxString retval;
|
||||||
return wxString();
|
if ( ret )
|
||||||
|
{
|
||||||
|
// Note that we must copy the returned value before calling setlocale()
|
||||||
|
// again as the string "ret" points to can (and, at least under Linux
|
||||||
|
// with glibc, actually always will) be changed by this call.
|
||||||
|
retval = ret;
|
||||||
|
wxSetlocale(LC_ALL, orig);
|
||||||
|
}
|
||||||
|
|
||||||
wxSetlocale(LC_ALL, orig);
|
return retval;
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user