From 17e24fec738a96168d6432b22ab225c4720e2319 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 8 May 2016 19:07:57 +0200 Subject: [PATCH] Fixed adding a line to wxGraphicsPath with GDI+ renderer. When current point is not yet set then wxGraphicsPath::AddLineToPoint() should behave as MoveToPoint(). See #17525 --- interface/wx/graphics.h | 6 +++++- src/msw/graphics.cpp | 9 ++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/interface/wx/graphics.h b/interface/wx/graphics.h index 8d15a41f6e..a6eef918fd 100644 --- a/interface/wx/graphics.h +++ b/interface/wx/graphics.h @@ -79,10 +79,14 @@ public: /** Adds a straight line from the current point to (@a x,@a y). + If current point is not yet set before the call to AddLineToPoint() + this function will behave as MoveToPoint(). */ virtual void AddLineToPoint(wxDouble x, wxDouble y); /** Adds a straight line from the current point to @a p. + If current point is not yet set before the call to AddLineToPoint() + this function will behave as MoveToPoint(). */ void AddLineToPoint(const wxPoint2DDouble& p); @@ -108,7 +112,7 @@ public: Appends a rounded rectangle as a new closed subpath. If @a radius equals 0 this function will behave as AddRectangle(), otherwise after this call the current point will be at - (@a x+@a w, @a y + @a h/2). + (@a x+@a w, @a y+@a h/2). */ virtual void AddRoundedRectangle(wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius); diff --git a/src/msw/graphics.cpp b/src/msw/graphics.cpp index 0c78abbdfd..1dae1e7737 100644 --- a/src/msw/graphics.cpp +++ b/src/msw/graphics.cpp @@ -1220,7 +1220,14 @@ void wxGDIPlusPathData::AddLineToPoint( wxDouble x , wxDouble y ) } else { - m_path->GetLastPoint(&start); + Status st = m_path->GetLastPoint(&start); + // If current point is not yet set then + // this function should behave as MoveToPoint. + if ( st != Ok ) + { + MoveToPoint(x, y); + return; + } } m_path->AddLine(start.X, start.Y, (REAL)x, (REAL)y); }