From bda3d86af93436fb611948634cf77035a1bc417c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 26 Sep 2003 16:55:53 +0000 Subject: [PATCH] don't do anything non trivial (like creating wxFontMapper) in ctors of global objects git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23935 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/strconv.h | 3 ++- src/common/strconv.cpp | 41 ++++++++++++++--------------------------- 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/include/wx/strconv.h b/include/wx/strconv.h index a5c89c2197..9248f2cb7e 100644 --- a/include/wx/strconv.h +++ b/include/wx/strconv.h @@ -188,7 +188,8 @@ private: // do create m_convReal (unconditionally) wxMBConv *DoCreate() const; - void SetEncoding(); + // set the name (may be only called when m_name == NULL), makes copy of + // charset string void SetName(const wxChar *charset); diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index bcb1a76a3a..dd7e60edfb 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -1247,37 +1247,21 @@ void wxCSConv::Init() m_deferred = true; } -// find a valid value for the encoding -void wxCSConv::SetEncoding() -{ -#if wxUSE_INTL - m_encoding = wxLocale::GetSystemEncoding(); -#else - m_encoding = wxFONTENCODING_SYSTEM; -#endif -} - wxCSConv::wxCSConv(const wxChar *charset) { Init(); if ( charset ) { - // not used - m_encoding = wxFONTENCODING_SYSTEM; - SetName(charset); } - else // no charset specified - { - SetEncoding(); - } + + m_encoding = wxFONTENCODING_SYSTEM; } wxCSConv::wxCSConv(wxFontEncoding encoding) { - if ( encoding == wxFONTENCODING_MAX || - encoding == wxFONTENCODING_DEFAULT ) + if ( encoding == wxFONTENCODING_MAX || encoding == wxFONTENCODING_DEFAULT ) { wxFAIL_MSG( _T("invalid encoding value in wxCSConv ctor") ); @@ -1286,14 +1270,7 @@ wxCSConv::wxCSConv(wxFontEncoding encoding) Init(); - if ( encoding == wxFONTENCODING_SYSTEM ) - { - SetEncoding(); - } - else // have valid encoding, use it - { - m_encoding = encoding; - } + m_encoding = encoding; } wxCSConv::~wxCSConv() @@ -1464,6 +1441,16 @@ void wxCSConv::CreateConvIfNeeded() const if ( m_deferred ) { wxCSConv *self = (wxCSConv *)this; // const_cast + +#if wxUSE_INTL + // if we don't have neither the name nor the encoding, use the default + // encoding for this system + if ( !m_name && m_encoding == wxFONTENCODING_SYSTEM ) + { + self->m_encoding = wxLocale::GetSystemEncoding(); + } +#endif // wxUSE_INTL + self->m_convReal = DoCreate(); self->m_deferred = false; }