From: Vadim Zeitlin Date: Fri, 24 Oct 2003 21:50:00 +0000 (+0000) Subject: use iconv() for wxCSConv constructed from a wxFontEncoding; don't use wxFontMapper... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/c547282d5e0205b5dab200d36b7f76f629f7a8fe use iconv() for wxCSConv constructed from a wxFontEncoding; don't use wxFontMapper unless really needed; when it is used, don't use it interactively git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24288 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index 840a24d54b..ffd70ff003 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -1317,28 +1317,12 @@ void wxCSConv::SetName(const wxChar *charset) } } -static inline bool DoesntNeedConv(wxFontEncoding enc) -{ - return enc == wxFONTENCODING_DEFAULT || - enc == wxFONTENCODING_SYSTEM || - enc == wxFONTENCODING_ISO8859_1; -} - wxMBConv *wxCSConv::DoCreate() const { -#if wxUSE_FONTMAP - wxFontMapper * const fontMapper = wxFontMapper::Get(); - - wxFontEncoding encFromName = m_name ? fontMapper->CharsetToEncoding(m_name) - : wxFONTENCODING_SYSTEM; -#endif // wxUSE_FONTMAP - - // check for the special case of ASCII charset - if ( (!m_name && DoesntNeedConv(m_encoding)) -#if wxUSE_FONTMAP - || (m_name && DoesntNeedConv(encFromName)) -#endif // wxUSE_FONTMAP - ) + // check for the special case of ASCII or ISO8859-1 charset: as we have + // special knowledge of it anyhow, we don't need to create a special + // conversion object + if ( m_encoding == wxFONTENCODING_ISO8859_1 ) { // don't convert at all return NULL; @@ -1354,9 +1338,18 @@ wxMBConv *wxCSConv::DoCreate() const // step (1) #ifdef HAVE_ICONV +#if !wxUSE_FONTMAP if ( m_name ) +#endif // !wxUSE_FONTMAP { - wxMBConv_iconv *conv = new wxMBConv_iconv(m_name); + wxString name(m_name); + +#if wxUSE_FONTMAP + if ( name.empty() ) + name = wxFontMapper::Get()->GetEncodingName(m_encoding); +#endif // wxUSE_FONTMAP + + wxMBConv_iconv *conv = new wxMBConv_iconv(name); if ( conv->IsOk() ) return conv; @@ -1378,8 +1371,13 @@ wxMBConv *wxCSConv::DoCreate() const // step (2) wxFontEncoding enc = m_encoding; #if wxUSE_FONTMAP - if ( enc == wxFONTENCODING_SYSTEM ) - enc = encFromName; + if ( enc == wxFONTENCODING_SYSTEM && m_name ) + { + // use "false" to suppress interactive dialogs -- we can be called from + // anywhere and popping up a dialog from here is the last thing we want to + // do + enc = wxFontMapper::Get()->CharsetToEncoding(m_name, false); + } #endif // wxUSE_FONTMAP switch ( enc )