From: Romulo Pinho Date: Fri, 5 Aug 2011 07:43:39 +0000 (+0200) Subject: solved locale related bug X-Git-Tag: v1.3.0~240^2~11 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=5f4539e40d4dd29c2a4768247feb384ffaa2bd02;p=clitk.git solved locale related bug - problem appeared when opening dicom files in a "French" machine --- diff --git a/vv/vv.cxx b/vv/vv.cxx index 93b708e..546f68a 100644 --- a/vv/vv.cxx +++ b/vv/vv.cxx @@ -62,7 +62,7 @@ std::string create_timed_string() } //------------------------------------------------------------------------------ -#ifdef _WIN32 +#ifdef _WIN32 int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, LPSTR lpCmdLine, int nShowCmd) { int argc = __argc; @@ -76,6 +76,23 @@ int main( int argc, char** argv ) QApplication app( argc, argv ); Q_INIT_RESOURCE(vvIcons); + + // + // ATTENTION: Rômulo Pinho - 05/08/2011 + // Forcing the locale of the application is necessary + // because QT initialization changes it to the locale + // of the language of the system. This can cause + // inconsistencies when, e.g., reading float values + // from DICOM fields with gdcm, since the decimal + // point may be changed for a comma (as in French). + // In practice, functions such as scanf and its + // variations are directly affected. + // https://bugreports.qt.nokia.com//browse/QTBUG-15247?page=com.atlassian.jira.plugin.system.issuetabpanels%253Achangehistory-tabpanel + // +#ifndef _WIN32 + std::string old_locale = setlocale(LC_NUMERIC, NULL); + setlocale(LC_NUMERIC, "POSIX"); +#endif vvMainWindow window; @@ -179,5 +196,10 @@ int main( int argc, char** argv ) window.ApplyWindowLevelToAllImages(); } +#ifndef _WIN32 + // restoring the locale, just to be clean... + setlocale(LC_NUMERIC, old_locale.c_str()); +#endif + return app.exec(); }