From c7b0a4855093020bde01428d0a93cb220aef1c9c Mon Sep 17 00:00:00 2001 From: Ben Grabow Date: Wed, 7 Dec 2016 17:50:55 -0600 Subject: [PATCH 1/2] Fix crash when merging activities. We now place a reasonable upper limit on the number of ticks shown on an AllPlot chart to prevent unbounded memory allocation and crash when one of the activities to be merged has a wide data range due to large anomalous data points. --- src/Charts/AllPlot.cpp | 39 +++++++++++++++++---------------------- src/Charts/AllPlot.h | 1 + 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/Charts/AllPlot.cpp b/src/Charts/AllPlot.cpp index 666afc24a..9b54f63bc 100644 --- a/src/Charts/AllPlot.cpp +++ b/src/Charts/AllPlot.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include "qwt_plot_gapped_curve.h" @@ -2698,6 +2699,16 @@ AllPlot::replot() { QwtPlot::replot(); } +void +AllPlot::setAxisScaleDiv(const QwtAxisId& axis, double min, double max, double step) { + int maxMajorTicks = 0; + int maxMinorTicks = 0; + QwtPlot::setAxisScaleDiv(axis, + QwtLinearScaleEngine().divideScale( + min, max, maxMajorTicks, maxMinorTicks, step) + ); +} + void AllPlot::setYMax() { @@ -2793,12 +2804,8 @@ AllPlot::setYMax() while( ( qCeil(maxY / step) * labelWidth ) > axisHeight ) nextStep(step); } - QwtValueList xytick[QwtScaleDiv::NTickTypes]; - for (int i=0;iupdate(); } @@ -2865,10 +2872,6 @@ AllPlot::setYMax() while((qCeil(ymax / step) * labelWidth) > axisHeight) nextStep(step); } - QwtValueList xytick[QwtScaleDiv::NTickTypes]; - for (int i=0;i axisHeight) nextStep(step); } - QwtValueList xytick[QwtScaleDiv::NTickTypes]; - for (int i=0;i axisHeight ) nextStep(step); } - QwtValueList xytick[QwtScaleDiv::NTickTypes]; - for (int i=ymin;ialtCurve->setBaseline(ymin); } diff --git a/src/Charts/AllPlot.h b/src/Charts/AllPlot.h index ae283b3f0..c9ffa4170 100644 --- a/src/Charts/AllPlot.h +++ b/src/Charts/AllPlot.h @@ -750,6 +750,7 @@ class AllPlot : public QwtPlot QFont labelFont; void setAltSlopePlotStyle (AllPlotSlopeCurve *curve); + void setAxisScaleDiv(const QwtAxisId&, double, double, double); static inline void nextStep( int& step ) { if (step >= 5000) { From d62612dbef7ff208fe5a0e0fbf65f59c99c33ba1 Mon Sep 17 00:00:00 2001 From: Ben Grabow Date: Wed, 7 Dec 2016 18:00:14 -0600 Subject: [PATCH 2/2] Remove unused header reference. --- src/Charts/AllPlot.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Charts/AllPlot.cpp b/src/Charts/AllPlot.cpp index 9b54f63bc..15a8e31bb 100644 --- a/src/Charts/AllPlot.cpp +++ b/src/Charts/AllPlot.cpp @@ -44,7 +44,6 @@ #include #include #include -#include #include #include #include