]> 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 8936454dfe22886d4e19cedaf0c443d4346436d7..742feb387f01c8db6781fd9f3ba3a1f6cfc0b1f3 100644 (file)
@@ -3339,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
     }