Histogram Compare Fixup

.. remember we can plot for a season and recognise that
   when checking for isCompareIntervals in PowerHist.

.. fixes a SEGV when looking at a histogram in the trends
   view whilst compare intervals is active in ride view.
This commit is contained in:
Mark Liversedge
2014-01-16 22:55:04 +00:00
parent bbb3a1ddc5
commit f06c5d0624
3 changed files with 9 additions and 7 deletions

View File

@@ -82,7 +82,7 @@ HistogramWindow::HistogramWindow(Context *context, bool rangemode) : GcChartWind
// plot
QVBoxLayout *vlayout = new QVBoxLayout;
vlayout->setSpacing(10);
powerHist = new PowerHist(context);
powerHist = new PowerHist(context, rangemode);
vlayout->addWidget(powerHist);
setChartLayout(vlayout);

View File

@@ -45,9 +45,10 @@
#include "LTMCanvasPicker.h" // for tooltip
PowerHist::PowerHist(Context *context):
PowerHist::PowerHist(Context *context, bool rangemode) :
minX(0),
maxX(0),
rangemode(rangemode),
rideItem(NULL),
context(context),
series(RideFile::watts),
@@ -303,7 +304,7 @@ PowerHist::recalcCompareIntervals()
// Set curves .. they will always have been created
// in setDataFromCompareIntervals, but no samples set
if (!isVisible() && !context->isCompareIntervals) return;
if (!isVisible() && (rangemode || !context->isCompareIntervals)) return;
double ncols = 0;
foreach(CompareInterval x, context->compareIntervals) {
@@ -540,7 +541,7 @@ PowerHist::recalcCompareIntervals()
void
PowerHist::recalc(bool force)
{
if (context->isCompareIntervals) { //XXX bodge for now
if (!rangemode && context->isCompareIntervals) {
recalcCompareIntervals();
return;
}
@@ -831,7 +832,7 @@ PowerHist::setYMax()
{
double MaxY=0;
if (context->isCompareIntervals) {
if (!rangemode && context->isCompareIntervals) {
int i=0;
foreach (QwtPlotCurve *p, compareCurves) {
@@ -1034,7 +1035,7 @@ void
PowerHist::setComparePens()
{
// no compare? don't bother
if (!context->isCompareIntervals) return;
if (rangemode || !context->isCompareIntervals) return;
double width = appsettings->value(this, GC_LINEWIDTH, 2.0).toDouble();
for (int i=0; i<context->compareIntervals.count(); i++) {

View File

@@ -116,11 +116,12 @@ class PowerHist : public QwtPlot
public:
PowerHist(Context *context);
PowerHist(Context *context, bool rangemode);
~PowerHist();
double minX;
double maxX;
bool rangemode;
public slots: