X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/574c939ef1c1b835a8bc65c0fe724548fa04ec49..757cc9def70e4685054f4a24238e2df111f6c9fd:/src/common/strconv.cpp diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index c8207ca44e..bdb210d538 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -42,6 +42,7 @@ #include #include +#include "wx/module.h" #include "wx/strconv.h" // ---------------------------------------------------------------------------- @@ -58,6 +59,24 @@ WXDLLEXPORT_DATA(wxMBConv *) wxConvCurrent = &wxConvLibc; +class wxStrConvModule: public wxModule +{ +public: + wxStrConvModule() : wxModule() { } + virtual bool OnInit() { return TRUE; } + virtual void OnExit() + { +#if wxUSE_WCHAR_T + wxConvLocal.Clear(); +#endif + } + + DECLARE_DYNAMIC_CLASS(wxStrConvModule) +}; + +IMPLEMENT_DYNAMIC_CLASS(wxStrConvModule, wxModule) + + // ---------------------------------------------------------------------------- // headers // ---------------------------------------------------------------------------- @@ -772,7 +791,7 @@ public: enc(wxFONTENCODING_SYSTEM) { if (name) - enc = wxTheFontMapper->CharsetToEncoding(name, FALSE); + enc = wxFontMapper::Get()->CharsetToEncoding(name, FALSE); m_ok = m2w.Init(enc, wxFONTENCODING_UNICODE) && w2m.Init(wxFONTENCODING_UNICODE, enc); @@ -821,7 +840,7 @@ static wxCharacterSet *wxGetCharacterSet(const wxChar *name) { // check for the special case of ASCII charset #if wxUSE_FONTMAP - if ( wxTheFontMapper->CharsetToEncoding(name) == wxFONTENCODING_DEFAULT ) + if ( wxFontMapper::Get()->CharsetToEncoding(name) == wxFONTENCODING_DEFAULT ) #else // wxUSE_FONTMAP if ( !name ) #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP @@ -898,8 +917,31 @@ wxCSConv::wxCSConv(const wxChar *charset) wxCSConv::~wxCSConv() { - free(m_name); - delete m_cset; + Clear(); +} + +wxCSConv::wxCSConv(const wxCSConv& conv) + : wxMBConv() +{ + Clear(); + SetName(conv.m_name); +} + +wxCSConv& wxCSConv::operator=(const wxCSConv& conv) +{ + Clear(); + SetName(conv.m_name); + return *this; +} + +void wxCSConv::Clear() +{ + if (m_name) + free(m_name); + if (m_cset) + delete m_cset; + m_name = NULL; + m_cset = NULL; } void wxCSConv::SetName(const wxChar *charset)