mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +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)
|
||||
{
|
||||
auto oldLocale = ::setlocale (LC_ALL, "");
|
||||
auto result = String::fromUTF8 (nl_langinfo (key));
|
||||
::setlocale (LC_ALL, oldLocale);
|
||||
return result;
|
||||
const String oldLocale { ::setlocale (LC_ALL, nullptr) };
|
||||
const ScopeGuard restore { [oldLocale] { ::setlocale (LC_ALL, oldLocale.toRawUTF8()); } };
|
||||
|
||||
::setlocale (LC_ALL, ""); // restore locale from env
|
||||
return String::fromUTF8 (nl_langinfo (key));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue