]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix totally broken LocaleSetter class in the test suite.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 15 Jul 2013 01:31:47 +0000 (01:31 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 15 Jul 2013 01:31:47 +0000 (01:31 +0000)
It was based on a completely erroneous assumption that setlocale() returns the
locale that had been previously active when it actually returns the newly set
locale.

This fixes unit test failures in StringTestCase under OS X, as the locale
wasn't correctly restored by DateTimeTestCase that used this class.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74522 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

tests/testprec.h

index 0005f5bb3ea42d75eac92fa78e615e0216cc4980..3e8ed28a63414bcc8c82dba84590b4b0cfe52395 100644 (file)
@@ -132,11 +132,20 @@ extern bool IsAutomaticTest();
 class LocaleSetter
 {
 public:
-    LocaleSetter(const char *loc) : m_locOld(setlocale(LC_ALL, loc)) { }
-    ~LocaleSetter() { setlocale(LC_ALL, m_locOld); }
+    LocaleSetter(const char *loc)
+        : m_locOld(wxStrdupA(setlocale(LC_ALL, NULL)))
+    {
+        setlocale(LC_ALL, loc);
+    }
+
+    ~LocaleSetter()
+    {
+        setlocale(LC_ALL, m_locOld);
+        free(m_locOld);
+    }
 
 private:
-    const char * const m_locOld;
+    char * const m_locOld;
 
     wxDECLARE_NO_COPY_CLASS(LocaleSetter);
 };