diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-01-10 16:07:57 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-01-10 16:07:57 -0500 |
commit | 3020b224fa2d6e1b6b8a576e8e8e211e0585f2a2 (patch) | |
tree | 314c3099bcc57d9af09d249e1e7dd8e45baca642 /libs/pbd/localeguard.cc | |
parent | d15fda6d751a465d278f477923075d4783f3b1ca (diff) | |
parent | 897fbdc652434d3aa1e67223c3c3ef7ae9be2318 (diff) |
Merge windows+cc branch into cairocanvas branch. Not finished, need to now merge windows branch to get changes from there
Diffstat (limited to 'libs/pbd/localeguard.cc')
-rw-r--r-- | libs/pbd/localeguard.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libs/pbd/localeguard.cc b/libs/pbd/localeguard.cc new file mode 100644 index 0000000000..12093beeaa --- /dev/null +++ b/libs/pbd/localeguard.cc @@ -0,0 +1,34 @@ +#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 ((char*)old); + } +} + + |