mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
SystemStats (Linux): Fix locale clobbering
This fixes a bug where the wrong locale was being restored when querying locale information.
This commit is contained in:
parent
a2a9c54e31
commit
2da6a5fb62
1 changed files with 5 additions and 4 deletions
|
|
@ -43,10 +43,11 @@ static String getCpuInfo (const char* key)
|
||||||
|
|
||||||
static String getLocaleValue (nl_item key)
|
static String getLocaleValue (nl_item key)
|
||||||
{
|
{
|
||||||
auto oldLocale = ::setlocale (LC_ALL, "");
|
const String oldLocale { ::setlocale (LC_ALL, nullptr) };
|
||||||
auto result = String::fromUTF8 (nl_langinfo (key));
|
const ScopeGuard restore { [oldLocale] { ::setlocale (LC_ALL, oldLocale.toRawUTF8()); } };
|
||||||
::setlocale (LC_ALL, oldLocale);
|
|
||||||
return result;
|
::setlocale (LC_ALL, ""); // restore locale from env
|
||||||
|
return String::fromUTF8 (nl_langinfo (key));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue