X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d0f93bc7dcf35f0e136cd8a5fa22ad6bdf1c2501..b25278d885906c601a53fe4ddb246da2f68f66f9:/src/common/dcgraph.cpp diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index 1f7295a12e..9dc59efb53 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -121,6 +121,12 @@ wxGCDC::wxGCDC(const wxEnhMetaFileDC& dc) } #endif +wxGCDC::wxGCDC(wxGraphicsContext* context) : + wxDC( new wxGCDCImpl( this ) ) +{ + SetGraphicsContext(context); +} + wxGCDC::wxGCDC() : wxDC( new wxGCDCImpl( this ) ) { @@ -181,13 +187,7 @@ wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxMemoryDC& dc ) : { Init(); wxGraphicsContext* context; -#if wxUSE_CAIRO - wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetCairoRenderer(); - context = renderer->CreateContext(dc); -#else context = wxGraphicsContext::Create(dc); -#endif - SetGraphicsContext( context ); } @@ -382,7 +382,10 @@ void wxGCDCImpl::SetTextForeground( const wxColour &col ) { wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::SetTextForeground - invalid DC") ); - if ( col != m_textForegroundColour ) + // don't set m_textForegroundColour to an invalid colour as we'd crash + // later then (we use m_textForegroundColour.GetColor() without checking + // in a few places) + if ( col.IsOk() && col != m_textForegroundColour ) { m_textForegroundColour = col; m_graphicContext->SetFont( m_font, m_textForegroundColour );