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
This commit is contained in:
Vadim Zeitlin 2003-09-26 16:55:53 +00:00
parent 03c0e93785
commit bda3d86af9
2 changed files with 16 additions and 28 deletions

View File

@ -188,7 +188,8 @@ private:
// do create m_convReal (unconditionally) // do create m_convReal (unconditionally)
wxMBConv *DoCreate() const; 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); void SetName(const wxChar *charset);

View File

@ -1247,37 +1247,21 @@ void wxCSConv::Init()
m_deferred = true; 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) wxCSConv::wxCSConv(const wxChar *charset)
{ {
Init(); Init();
if ( charset ) if ( charset )
{ {
// not used
m_encoding = wxFONTENCODING_SYSTEM;
SetName(charset); SetName(charset);
} }
else // no charset specified
{ m_encoding = wxFONTENCODING_SYSTEM;
SetEncoding();
}
} }
wxCSConv::wxCSConv(wxFontEncoding encoding) wxCSConv::wxCSConv(wxFontEncoding encoding)
{ {
if ( encoding == wxFONTENCODING_MAX || if ( encoding == wxFONTENCODING_MAX || encoding == wxFONTENCODING_DEFAULT )
encoding == wxFONTENCODING_DEFAULT )
{ {
wxFAIL_MSG( _T("invalid encoding value in wxCSConv ctor") ); wxFAIL_MSG( _T("invalid encoding value in wxCSConv ctor") );
@ -1286,14 +1270,7 @@ wxCSConv::wxCSConv(wxFontEncoding encoding)
Init(); Init();
if ( encoding == wxFONTENCODING_SYSTEM )
{
SetEncoding();
}
else // have valid encoding, use it
{
m_encoding = encoding; m_encoding = encoding;
}
} }
wxCSConv::~wxCSConv() wxCSConv::~wxCSConv()
@ -1464,6 +1441,16 @@ void wxCSConv::CreateConvIfNeeded() const
if ( m_deferred ) if ( m_deferred )
{ {
wxCSConv *self = (wxCSConv *)this; // const_cast 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_convReal = DoCreate();
self->m_deferred = false; self->m_deferred = false;
} }