summaryrefslogtreecommitdiff
path: root/libs/pbd
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-01-30 18:10:50 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-01-30 18:10:50 +0000
commitd7707af16b008129ba98e9bd2187fcd4c7a0b299 (patch)
tree4f2da4ad4881528eeaaa237781b03b66be79accb /libs/pbd
parent06c8a2baefdb909e40be3c3656ee845de46db310 (diff)
move LocaleGuard "up" into libpbd; use LocaleGuard to replace utterly broken std::locale() in Gtkmm2ext::BarController handling of logarithmic values
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@6598 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd')
-rw-r--r--libs/pbd/SConscript1
-rw-r--r--libs/pbd/localeguard.cc21
-rw-r--r--libs/pbd/pbd/localeguard.h33
3 files changed, 55 insertions, 0 deletions
diff --git a/libs/pbd/SConscript b/libs/pbd/SConscript
index 96d1a772b5..b33ab58173 100644
--- a/libs/pbd/SConscript
+++ b/libs/pbd/SConscript
@@ -29,6 +29,7 @@ dmalloc.cc
error.cc
fpu.cc
id.cc
+localeguard.cc
mountpoint.cc
path.cc
pathscanner.cc
diff --git a/libs/pbd/localeguard.cc b/libs/pbd/localeguard.cc
new file mode 100644
index 0000000000..a97a99bfd3
--- /dev/null
+++ b/libs/pbd/localeguard.cc
@@ -0,0 +1,21 @@
+#include <cstring>
+#include <locale.h>
+#include <stdlib.h>
+
+#include "pbd/localeguard.h"
+
+PBD::LocaleGuard::LocaleGuard (const char* str)
+{
+ old = strdup (setlocale (LC_NUMERIC, NULL));
+ if (strcmp (old, str)) {
+ setlocale (LC_NUMERIC, str);
+ }
+}
+
+PBD::LocaleGuard::~LocaleGuard ()
+{
+ setlocale (LC_NUMERIC, old);
+ free ((char*)old);
+}
+
+
diff --git a/libs/pbd/pbd/localeguard.h b/libs/pbd/pbd/localeguard.h
new file mode 100644
index 0000000000..e03e4ce4f2
--- /dev/null
+++ b/libs/pbd/pbd/localeguard.h
@@ -0,0 +1,33 @@
+/*
+ Copyright (C) 1999-2010 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef __pbd_localeguard_h__
+#define __pbd_localeguard_h__
+
+namespace PBD {
+
+struct LocaleGuard {
+ LocaleGuard (const char*);
+ ~LocaleGuard ();
+ const char* old;
+};
+
+}; // namespace
+
+#endif /* __pbd_localeguard_h__ */