Files
ardour/libs/pbd/localeguard.cc
2015-02-27 14:21:45 -05:00

37 lines
687 B
C++

#include <cstring>
#include <locale.h>
#include <stdlib.h>
#include "pbd/localeguard.h"
// JE - added temporarily, to reduce the delay effects when calling
// setlocale() recursively in a Windows GUI thread (we should think
// about moving the caller(s) into a dedicated worker thread).
std::string PBD::LocaleGuard::current;
PBD::LocaleGuard::LocaleGuard (const char* str)
: old(0)
{
if (current != str) {
old = strdup (setlocale (LC_NUMERIC, NULL));
if (strcmp (old, str)) {
if (setlocale (LC_NUMERIC, str)) {
current = str;
}
}
}
}
PBD::LocaleGuard::~LocaleGuard ()
{
if (old) {
if (setlocale (LC_NUMERIC, old)) {
current = old;
}
free (old);
}
}