From fe24e4e9c297776351b0a6b8beafd9c7c3433148 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 22 Oct 2012 15:51:49 +0000 Subject: [PATCH] Set C++ global locale too in wxAppTraitsBase::SetLocale(). Ensure that C++ locale matches the C one, otherwise operations on C++ streams may get much slower because some implementations (notable MinGW-64) change and reset the C locale on every function call in this case. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72719 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/appbase.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/common/appbase.cpp b/src/common/appbase.cpp index 57e0912e2e..ac7d977062 100644 --- a/src/common/appbase.cpp +++ b/src/common/appbase.cpp @@ -47,10 +47,15 @@ #include "wx/tokenzr.h" #include "wx/thread.h" -#if wxUSE_EXCEPTIONS && wxUSE_STL - #include - #include -#endif +#if wxUSE_STL + #if wxUSE_EXCEPTIONS + #include + #include + #endif + #if wxUSE_INTL + #include + #endif +#endif // wxUSE_STL #if !defined(__WINDOWS__) || defined(__WXMICROWIN__) #include // for SIGTRAP used by wxTrap() @@ -834,7 +839,19 @@ bool wxConsoleAppTraitsBase::HasStderr() #if wxUSE_INTL void wxAppTraitsBase::SetLocale() { + // We want to use the user locale by default in GUI applications in order + // to show the numbers, dates &c in the familiar format -- and also accept + // this format on input (especially important for decimal comma/dot). wxSetlocale(LC_ALL, ""); + +#if wxUSE_STL + // At least in some environments, e.g. MinGW-64, if the global C++ locale + // is different from the global C locale, all stream operations temporarily + // change the locale resulting in a huge slowdown (3 times slower in some + // real-life applications), so change the C++ locale to match. + std::locale::global(std::locale("")); +#endif //wxUSE_STL + wxUpdateLocaleIsUtf8(); } #endif -- 2.45.2