diff --git a/interface/wx/dc.h b/interface/wx/dc.h index 2f28a7b869..36482c7f5d 100644 --- a/interface/wx/dc.h +++ b/interface/wx/dc.h @@ -714,7 +714,7 @@ public: /** Draws a spline between all given points using the current pen. - The number of points must be at least 3 for the spline to be drawn. + The number of points must be at least 2 for the spline to be drawn. @beginWxPerlOnly Not supported by wxPerl. diff --git a/src/common/dcbase.cpp b/src/common/dcbase.cpp index fd964d69cc..9acb3a73a8 100644 --- a/src/common/dcbase.cpp +++ b/src/common/dcbase.cpp @@ -903,16 +903,14 @@ static void wx_spline_draw_point_array(wxDC *dc) void wxDCImpl::DoDrawSpline( const wxPointList *points ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); + wxCHECK_RET(points, "NULL pointer to spline points?"); + wxCHECK_RET(points->GetCount() >= 2, "incomplete list of spline points?"); const wxPoint *p; double cx1, cy1, cx2, cy2; double x1, y1, x2, y2; wxPointList::compatibility_iterator node = points->GetFirst(); - if (!node) - // empty list - return; - p = node->GetData(); x1 = p->x; diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index 7c7fe2518e..241766a865 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -846,6 +846,8 @@ void wxGCDCImpl::DoDrawLines(int n, const wxPoint points[], void wxGCDCImpl::DoDrawSpline(const wxPointList *points) { wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawSpline - invalid DC") ); + wxCHECK_RET(points, "NULL pointer to spline points?"); + wxCHECK_RET(points->GetCount() >= 2, "incomplete list of spline points?"); if ( !m_logicalFunctionSupported ) return; @@ -853,10 +855,6 @@ void wxGCDCImpl::DoDrawSpline(const wxPointList *points) wxGraphicsPath path = m_graphicContext->CreatePath(); wxPointList::compatibility_iterator node = points->GetFirst(); - if ( !node ) - // empty list - return; - const wxPoint *p = node->GetData(); wxCoord x1 = p->x; diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index 03119d0211..87fe8487c3 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -1463,6 +1463,8 @@ void wxPostScriptDCImpl::SetLogicalFunction(wxRasterOperationMode WXUNUSED(funct void wxPostScriptDCImpl::DoDrawSpline( const wxPointList *points ) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); + wxCHECK_RET(points, "NULL pointer to spline points?"); + wxCHECK_RET(points->GetCount() >= 2, "incomplete list of spline points?"); SetPen( m_pen ); diff --git a/src/gtk/print.cpp b/src/gtk/print.cpp index 751fb2afc5..e263b23561 100644 --- a/src/gtk/print.cpp +++ b/src/gtk/print.cpp @@ -1716,6 +1716,9 @@ void wxGtkPrinterDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCo #if wxUSE_SPLINES void wxGtkPrinterDCImpl::DoDrawSpline(const wxPointList *points) { + wxCHECK_RET(points, "NULL pointer to spline points?"); + wxCHECK_RET(points->GetCount() >= 2, "incomplete list of spline points?"); + SetPen (m_pen); double c, d, x1, y1, x3, y3; diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index eee91b4c55..de310cf35e 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -1158,10 +1158,10 @@ void wxMSWDCImpl::DoDrawSpline(const wxPointList *points) // B2 = (2*P1 + P2)/3 // B3 = P2 - wxASSERT_MSG( points, wxT("NULL pointer to spline points?") ); + wxCHECK_RET( points, "NULL pointer to spline points?" ); const size_t n_points = points->GetCount(); - wxASSERT_MSG( n_points > 2 , wxT("incomplete list of spline points?") ); + wxCHECK_RET( n_points >= 2 , "incomplete list of spline points?" ); const size_t n_bezier_points = n_points * 3 + 1; POINT *lppt = new POINT[n_bezier_points];