Don't call setlocale("") on startup by default any longer.

This undoes the changes of r44773 because calling setlocale() resulted in C
locale being set differently from C++ locale which was confusing and led to
huge slowdowns in any code using std::stream with at least MinGW. And setting
the C++ locale to be the same, as r72719 tried to do, doesn't seem to be
practical as it results in immediate crashes under OS X and MinGW when used
under XP.

Do provide wxApp::SetCLocale() helper to explicitly do what was previously
done implicitly, even though currently it is a trivial wrapper for setlocale()
and we don't even need to call gtk_set_locale() as it has never done anything
else and is deprecated since GTK+ 2.24.

Closes #14780.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72951 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-11-14 13:46:50 +00:00
parent 40df8a51f2
commit b51014176a
9 changed files with 65 additions and 64 deletions

View File

@@ -309,9 +309,9 @@ bool wxApp::Initialize(int& argc_, wxChar **argv_)
if (encName.CmpNoCase(wxT("@locale")) == 0)
encName.clear();
encName.MakeUpper();
#if wxUSE_INTL
if (encName.empty())
{
#if wxUSE_INTL
// (2) if a non default locale is set, assume that the user wants his
// filenames in this locale too
encName = wxLocale::GetSystemEncodingName().Upper();
@@ -330,22 +330,14 @@ bool wxApp::Initialize(int& argc_, wxChar **argv_)
encName.clear();
}
}
#endif // wxUSE_INTL
// (3) finally use UTF-8 by default
if ( encName.empty() )
encName = wxT("UTF-8");
wxSetEnv(wxT("G_FILENAME_ENCODING"), encName);
}
#else
if (encName.empty())
encName = wxT("UTF-8");
// if wxUSE_INTL==0 it probably indicates that only "C" locale is supported
// by the program anyhow so prevent GTK+ from calling setlocale(LC_ALL, "")
// from gtk_init_check() as it does by default
gtk_disable_setlocale();
#endif // wxUSE_INTL
static wxConvBrokenFileNames fileconv(encName);
wxConvFileName = &fileconv;
#endif // __UNIX__
@@ -366,13 +358,17 @@ bool wxApp::Initialize(int& argc_, wxChar **argv_)
int argcGTK = argc_;
// Prevent gtk_init_check() from changing the locale automatically for
// consistency with the other ports that don't do it. If necessary,
// wxApp::SetCLocale() may be explicitly called.
gtk_disable_setlocale();
#ifdef __WXGPE__
init_result = true; // is there a _check() version of this?
gpe_application_init( &argcGTK, &argvGTK );
#else
init_result = gtk_init_check( &argcGTK, &argvGTK ) != 0;
#endif
wxUpdateLocaleIsUtf8();
if ( argcGTK != argc_ )
{