]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/strconv.cpp
return false from OnInit() in console build if we failed
[wxWidgets.git] / src / common / strconv.cpp
index 06f7637db84f7ed735a63d4e5c2a3fad2b9b6268..52f1a41c1781537972505bd394caf7c93c76516c 100644 (file)
@@ -2229,11 +2229,11 @@ private:
             int verMaj, verMin;
             switch ( wxGetOsVersion(&verMaj, &verMin) )
             {
-                case wxWIN95:
+                case wxOS_WINDOWS_9X:
                     s_isWin98Or2k = verMaj >= 4 && verMin >= 10;
                     break;
 
-                case wxWINDOWS_NT:
+                case wxOS_WINDOWS_NT:
                     s_isWin98Or2k = verMaj >= 5;
                     break;
 
@@ -3306,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() )
         {
@@ -3337,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
     }
@@ -3475,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
               );
 
@@ -3491,14 +3499,17 @@ void wxCSConv::CreateConvIfNeeded() const
     {
         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 )
         {
+#if wxUSE_INTL
             self->m_name = wxStrdup(wxLocale::GetSystemEncodingName());
-        }
+#else
+            // fallback to some reasonable default:
+            self->m_encoding = wxFONTENCODING_ISO8859_1;
 #endif // wxUSE_INTL
+        }
 
         self->m_convReal = DoCreate();
         self->m_deferred = false;