Fix incorrect use of setlocale() in wxLocale::IsAvailable().

The return value of setlocale() was used incorrectly in this code: it
represents the newly set locale and not the previously active one so we didn't
actually restore the original locale before.

Fix the code and check that we do actually restore the locale in a new unit
test for it.

See #13117.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67405 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-04-06 14:37:27 +00:00
parent 3668a4f69e
commit fd1c361c33
2 changed files with 25 additions and 8 deletions

View File

@@ -43,12 +43,14 @@ private:
CPPUNIT_TEST( Headers );
CPPUNIT_TEST( DateTimeFmtFrench );
CPPUNIT_TEST( DateTimeFmtC );
CPPUNIT_TEST( IsAvailable );
CPPUNIT_TEST_SUITE_END();
void Domain();
void Headers();
void DateTimeFmtFrench();
void DateTimeFmtC();
void IsAvailable();
wxLocale *m_locale;
@@ -204,4 +206,14 @@ void IntlTestCase::DateTimeFmtC()
m_locale->GetInfo(wxLOCALE_TIME_FMT) );
}
void IntlTestCase::IsAvailable()
{
const wxString origLocale(setlocale(LC_ALL, NULL));
// Calling IsAvailable() shouldn't change the locale.
wxLocale::IsAvailable(wxLANGUAGE_ENGLISH);
CPPUNIT_ASSERT_EQUAL( origLocale, setlocale(LC_ALL, NULL) );
}
#endif // wxUSE_INTL