]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/strconv.cpp
Combine two wxImage-to-pixmap creation functions into one.
[wxWidgets.git] / src / common / strconv.cpp
index a603d02f18eeaee87abec04920ce164955230fe9..742feb387f01c8db6781fd9f3ba3a1f6cfc0b1f3 100644 (file)
@@ -1668,7 +1668,7 @@ wxMBConv_iconv::wxMBConv_iconv(const wxChar *name)
 #if wxUSE_FONTMAP
         const wxChar **names = wxFontMapperBase::GetAllEncodingNames(WC_ENC);
 #else // !wxUSE_FONTMAP
-        static const wxChar *names[] =
+        static const wxChar *names_static[] =
         {
 #if SIZEOF_WCHAR_T == 4
             _T("UCS-4"),
@@ -1677,6 +1677,7 @@ wxMBConv_iconv::wxMBConv_iconv(const wxChar *name)
 #endif
             NULL
         };
+        const wxChar **names = names_static;
 #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP
 
         for ( ; *names && ms_wcCharsetName.empty(); ++names )
@@ -3305,7 +3306,9 @@ wxMBConv *wxCSConv::DoCreate() const
 #endif // !wxUSE_FONTMAP
     {
         wxString name(m_name);
+#if wxUSE_FONTMAP
         wxFontEncoding encoding(m_encoding);
+#endif
 
         if ( !name.empty() )
         {
@@ -3336,20 +3339,26 @@ wxMBConv *wxCSConv::DoCreate() const
             }
 
             const wxChar** names = wxFontMapperBase::GetAllEncodingNames(encoding);
-
-            for ( ; *names; ++names )
+            // CS : in case this does not return valid names (eg for MacRoman) encoding
+            // got a 'failure' entry in the cache all the same, although it just has to 
+            // be created using a different method, so only store failed iconv creation
+            // attempts (or perhaps we shoulnd't do this at all ?)
+            if ( names[0] != NULL )
             {
-                wxMBConv_iconv *conv = new wxMBConv_iconv(*names);
-                if ( conv->IsOk() )
+                for ( ; *names; ++names )
                 {
-                    gs_nameCache[encoding] = *names;
-                    return conv;
+                    wxMBConv_iconv *conv = new wxMBConv_iconv(*names);
+                    if ( conv->IsOk() )
+                    {
+                        gs_nameCache[encoding] = *names;
+                        return conv;
+                    }
+
+                    delete conv;
                 }
 
-                delete conv;
+                gs_nameCache[encoding] = _T(""); // cache the failure
             }
-
-            gs_nameCache[encoding] = _T(""); // cache the failure
         }
 #endif // wxUSE_FONTMAP
     }
@@ -3474,7 +3483,7 @@ wxMBConv *wxCSConv::DoCreate() const
 #if wxUSE_FONTMAP
                          wxFontMapperBase::GetEncodingDescription(m_encoding).c_str()
 #else // !wxUSE_FONTMAP
-                         wxString::Format(_("encoding %s"), m_encoding).c_str()
+                         wxString::Format(_("encoding %i"), m_encoding).c_str()
 #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP
               );