[colobot] 281/390: Fixed updating C locale after exception in C++ locale, should finish fixing #445
Didier Raboud
odyx at moszumanska.debian.org
Fri Jun 12 14:21:55 UTC 2015
This is an automated email from the git hooks/post-receive script.
odyx pushed a commit to branch upstream/latest
in repository colobot.
commit bb16c6d97c3d76028066c870844c99ededcc3251
Author: krzys-h <krzys_h at interia.pl>
Date: Sat Mar 21 20:13:58 2015 +0100
Fixed updating C locale after exception in C++ locale, should finish fixing #445
---
src/app/app.cpp | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/app/app.cpp b/src/app/app.cpp
index 7941d69..b7c1a32 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -1683,10 +1683,11 @@ void CApplication::SetLanguage(Language language)
GetLogger()->Trace("SetLanguage: Set LANGUAGE=%s in environment\n", locale.c_str());
}
- setlocale(LC_ALL, ""); // Load system locale
+ char* defaultLocale = setlocale(LC_ALL, ""); // Load system locale
setlocale(LC_NUMERIC, "C"); // Force numeric locale to "C" (fixes decimal point problems)
char* systemLocale = setlocale(LC_ALL, nullptr); // Get current locale configuration
- GetLogger()->Debug("System locale: %s\n", systemLocale);
+ GetLogger()->Debug("Default system locale: %s\n", defaultLocale);
+ GetLogger()->Debug("Setting locale: %s\n", systemLocale);
// Update C++ locale
try
{
@@ -1698,12 +1699,15 @@ void CApplication::SetLanguage(Language language)
try
{
std::locale::global(std::locale::classic());
- setlocale(LC_ALL, systemLocale); // C locale might still work correctly
}
catch(...)
{
- GetLogger()->Warn("Failed to set classic locale. Something is really messed up in your system configuration. Translations probably won't work.\n");
+ GetLogger()->Warn("Failed to set classic locale. Something is really messed up in your system configuration. Translations might not work.\n");
}
+
+ // C locale might still work correctly
+ setlocale(LC_ALL, "");
+ setlocale(LC_NUMERIC, "C");
}
bindtextdomain("colobot", m_pathManager->GetLangPath().c_str());
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git
More information about the Pkg-games-commits
mailing list