Browse Source

Make changes in LOCALE_IO more easy (simplify locale_io.h).

No actual change in code.
pull/18/head
jean-pierre charras 6 months ago
parent
commit
3813cbd40b
  1. 11
      common/locale_io.cpp
  2. 15
      include/locale_io.h

11
common/locale_io.cpp

@ -24,6 +24,7 @@
#include <locale_io.h>
#include <wx/intl.h>
#include <clocale>
#include <atomic>
// When reading/writing files, we need to switch to setlocale( LC_NUMERIC, "C" ).
// Works fine to read/write files with floating point numbers.
@ -50,8 +51,18 @@
// On Windows, when using setlocale, a wx alert is generated
// in some cases (reading a bitmap for instance)
// So we disable alerts during the time a file is read or written
// set USE_WXLOCALE to 0 to use setlocale, 1 to use wxLocale:
#if defined( _WIN32 )
#define USE_WXLOCALE 1
#else
#define USE_WXLOCALE 0
#endif
#if !USE_WXLOCALE
#if defined( _WIN32 ) && defined( DEBUG )
#include <wx/appl.h> // for wxTheApp
// a wxAssertHandler_t function to filter wxWidgets alert messages when reading/writing a file
// when switching the locale to LC_NUMERIC, "C"

15
include/locale_io.h

@ -25,16 +25,8 @@
#define LOCALE_IO_H
#include <kicommon.h>
#include <atomic>
#include <string>
// set USE_WXLOCALE 0 to use setlocale, 1 to use wxLocale:
#if defined( _WIN32 )
#define USE_WXLOCALE 1
#else
#define USE_WXLOCALE 0
#endif
class wxLocale;
/**
@ -52,13 +44,10 @@ public:
~LOCALE_IO();
private:
#if USE_WXLOCALE
wxLocale* m_wxLocale;
#else
// The locale in use before switching to the "C" locale
// (the locale can be set by user, and is not always the system locale)
std::string m_user_locale;
#endif
wxLocale* m_wxLocale; // used when using wxLocale
std::string m_user_locale; // used when using setlocale or wxSetlocale
};
#endif
Loading…
Cancel
Save