]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/dc.cpp
fix for potention crash when conversion fails
[wxWidgets.git] / src / mac / carbon / dc.cpp
index 1d07f860742f8c50ef6b9db940aec53317544f10..eb8b35a402e8dc7d022dbceba46dacd634b324a5 100644 (file)
 #ifndef WX_PRECOMP
     #include "wx/log.h"
     #include "wx/app.h"
+    #include "wx/dcmemory.h"
+    #include "wx/dcprint.h"
+    #include "wx/region.h"
 #endif
 
 #include "wx/mac/uma.h"
-#include "wx/dcmemory.h"
-#include "wx/dcprint.h"
-#include "wx/region.h"
 #include "wx/image.h"
 
 #ifdef __MSL__
@@ -1650,7 +1650,8 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y)
 #endif
         {
             wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
-            ::DrawText( text , 0 , strlen(text) ) ;
+            if ( text.data() != NULL )
+                ::DrawText( text , 0 , strlen(text) ) ;
          }
     }
 
@@ -1718,7 +1719,10 @@ void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *he
         else
         {
             wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
-            curwidth = ::TextWidth( text , 0 , strlen(text) ) ;
+            if ( text.data() != NULL )
+                curwidth = ::TextWidth( text , 0 , strlen(text) ) ;
+            else
+                curwidth = 0 ;
         }
 
         if ( curwidth > *width )