]> git.saurik.com Git - wxWidgets.git/commitdiff
Do a sanity check to make sure GetWindow() has a valid window, and assert if it doesn...
authorKevin Ollivier <kevino@theolliviers.com>
Mon, 9 Feb 2009 02:21:30 +0000 (02:21 +0000)
committerKevin Ollivier <kevino@theolliviers.com>
Mon, 9 Feb 2009 02:21:30 +0000 (02:21 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58797 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/osx/carbon/graphics.cpp

index 6afb4468a4f2eb71ca2886cf9ff12ae06d7765f6..419a3b62597999960a12bded1df4188f3f295c0b 100644 (file)
@@ -2435,12 +2435,15 @@ wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContext( const wxWindowDC&
         int w, h;
         win_impl->GetSize( &w, &h );
         CGContextRef cgctx = 0;
-#ifdef __WXMAC__
-        cgctx =  (CGContextRef)(win_impl->GetWindow()->MacGetCGContextRef());
-#else
-        cgctx = wxMacGetContextFromCurrentNSContext() ;
+        wxASSERT_MSG(win_impl->GetWindow(), "Invalid wxWindow in wxMacCoreGraphicsRenderer::CreateContext");
+        if (win_impl->GetWindow())
+            cgctx =  (CGContextRef)(win_impl->GetWindow()->MacGetCGContextRef());
+#if wxOSX_USE_COCOA
+        else
+            cgctx = wxMacGetContextFromCurrentNSContext() ;
 #endif
-        return new wxMacCoreGraphicsContext( this, cgctx, (wxDouble) w, (wxDouble) h );
+        if (cgctx != 0)
+            return new wxMacCoreGraphicsContext( this, cgctx, (wxDouble) w, (wxDouble) h );
     }
     return NULL;
 }