Skip to content
Permalink
Browse files

Relax wxPaintDC assertion which fails on macOS 10.14

With macOS 10.14, wxGLCanvas windows have a NULL CGContextRef.  On master
this was fixed in #846 by
adding a new RequiresCGContextRef() virtual method but that's an
incompatible ABI change so not suitable for 3.0.x, but instead we can
check if the window is a subclass of wxGLCanvas using RTTI if the
CGContextRef is NULL.

Closes #1414
  • Loading branch information...
ojwb authored and vadz committed Jul 13, 2019
1 parent 2df389d commit 531fdbcb64b265e6f24f1f0cc7469f308b9fb697
Showing with 11 additions and 1 deletion.
  1. +11 −1 src/osx/carbon/dcclient.cpp
@@ -189,10 +189,20 @@ wxPaintDCImpl::wxPaintDCImpl( wxDC *owner )
{
}

#if wxDEBUG_LEVEL
static bool IsGLCanvas( wxWindow * window )
{
// If the wx gl library isn't loaded then ciGLCanvas will be NULL.
static const wxClassInfo* const ciGLCanvas = wxClassInfo::FindClass("wxGLCanvas");
return ciGLCanvas && window->IsKindOf(ciGLCanvas);
}
#endif

wxPaintDCImpl::wxPaintDCImpl( wxDC *owner, wxWindow *window ) :
wxWindowDCImpl( owner, window )
{
wxASSERT_MSG( window->MacGetCGContextRef() != NULL, wxT("using wxPaintDC without being in a native paint event") );
// With macOS 10.14, wxGLCanvas windows have a NULL CGContextRef.
wxASSERT_MSG( window->MacGetCGContextRef() != NULL || IsGLCanvas(window), wxT("using wxPaintDC without being in a native paint event") );
wxPoint origin = window->GetClientAreaOrigin() ;
m_window->GetClientSize( &m_width , &m_height);
SetDeviceOrigin( origin.x, origin.y );

0 comments on commit 531fdbc

Please sign in to comment.
You can’t perform that action at this time.