From 896d383a4dcc6bf428e29336d2c8c65ea552ca80 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Wed, 14 Oct 2020 12:09:34 -0700 Subject: [PATCH] Move some early-out code to the top of the function --- src/common/dcgraph.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index 2e3afe25fe..aebf3c3d7c 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -1210,6 +1210,11 @@ void wxGCDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, void wxGCDCImpl::DoDrawText(const wxString& str, wxCoord x, wxCoord y) { + wxCHECK_RET( IsOk(), "wxGCDC::DoDrawText - invalid DC" ); + + if ( str.empty() ) + return; + // For compatibility with other ports (notably wxGTK) and because it's // genuinely useful, we allow passing multiline strings to DrawText(). // However there is no native OSX function to draw them directly so we @@ -1222,11 +1227,6 @@ void wxGCDCImpl::DoDrawText(const wxString& str, wxCoord x, wxCoord y) return; } - wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawText - invalid DC") ); - - if ( str.empty() ) - return; - // Text drawing shouldn't be affected by the raster operation // mode set by SetLogicalFunction() and should be always done // in the default wxCOPY mode (which is wxCOMPOSITION_OVER @@ -1368,6 +1368,9 @@ void wxGCDCImpl::DoGradientFillLinear(const wxRect& rect, const wxColour& destColour, wxDirection nDirection ) { + if (rect.width == 0 || rect.height == 0) + return; + wxPoint start; wxPoint end; switch( nDirection) @@ -1396,9 +1399,6 @@ void wxGCDCImpl::DoGradientFillLinear(const wxRect& rect, break; } - if (rect.width == 0 || rect.height == 0) - return; - m_graphicContext->SetBrush( m_graphicContext->CreateLinearGradientBrush( start.x,start.y,end.x,end.y, initialColour, destColour)); m_graphicContext->SetPen(*wxTRANSPARENT_PEN);