diff --git a/src/common/dcbase.cpp b/src/common/dcbase.cpp index 9acb3a73a8..0bdebe200b 100644 --- a/src/common/dcbase.cpp +++ b/src/common/dcbase.cpp @@ -27,6 +27,7 @@ #include "wx/dcprint.h" #include "wx/prntbase.h" #include "wx/scopeguard.h" +#include "wx/stack.h" #ifndef WX_PRECOMP #include "wx/math.h" @@ -791,7 +792,7 @@ void wx_quadratic_spline(double a1, double b1, double a2, double b2, static void wx_clear_stack(); static -int wx_spline_pop(double *x1, double *y1, double *x2, double *y2, double *x3, +bool wx_spline_pop(double *x1, double *y1, double *x2, double *y2, double *x3, double *y3, double *x4, double *y4); static void wx_spline_push(double x1, double y1, double x2, double y2, double x3, double y3, @@ -837,47 +838,44 @@ typedef struct wx_spline_stack_struct { double x1, y1, x2, y2, x3, y3, x4, y4; } Stack; -#define SPLINE_STACK_DEPTH 20 -static Stack wx_spline_stack[SPLINE_STACK_DEPTH]; -static Stack *wx_stack_top; -static int wx_stack_count; +static wxStack gs_wx_spline_stack; void wx_clear_stack() { - wx_stack_top = wx_spline_stack; - wx_stack_count = 0; + gs_wx_spline_stack = wxStack(); } void wx_spline_push(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) { - wx_stack_top->x1 = x1; - wx_stack_top->y1 = y1; - wx_stack_top->x2 = x2; - wx_stack_top->y2 = y2; - wx_stack_top->x3 = x3; - wx_stack_top->y3 = y3; - wx_stack_top->x4 = x4; - wx_stack_top->y4 = y4; - wx_stack_top++; - wx_stack_count++; + Stack rec; + rec.x1 = x1; + rec.y1 = y1; + rec.x2 = x2; + rec.y2 = y2; + rec.x3 = x3; + rec.y3 = y3; + rec.x4 = x4; + rec.y4 = y4; + gs_wx_spline_stack.push(rec); } -int wx_spline_pop(double *x1, double *y1, double *x2, double *y2, - double *x3, double *y3, double *x4, double *y4) +bool wx_spline_pop(double *x1, double *y1, double *x2, double *y2, + double *x3, double *y3, double *x4, double *y4) { - if (wx_stack_count == 0) - return (0); - wx_stack_top--; - wx_stack_count--; - *x1 = wx_stack_top->x1; - *y1 = wx_stack_top->y1; - *x2 = wx_stack_top->x2; - *y2 = wx_stack_top->y2; - *x3 = wx_stack_top->x3; - *y3 = wx_stack_top->y3; - *x4 = wx_stack_top->x4; - *y4 = wx_stack_top->y4; - return (1); + if ( gs_wx_spline_stack.empty() ) + return false; + + const Stack& top = gs_wx_spline_stack.top(); + *x1 = top.x1; + *y1 = top.y1; + *x2 = top.x2; + *y2 = top.y2; + *x3 = top.x3; + *y3 = top.y3; + *x4 = top.x4; + *y4 = top.y4; + gs_wx_spline_stack.pop(); + return true; } static bool wx_spline_add_point(double x, double y)