From e1ee78ac7c7c7ab4264d14acac9a3c2b4403a2e2 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Sat, 27 Aug 2011 17:19:54 +0100 Subject: [PATCH] Fix AllPlot delete ride crash. Fixes #431. --- src/AllPlot.cpp | 5 ++++- src/AllPlotWindow.cpp | 15 +++++++++++++++ src/AllPlotWindow.h | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/AllPlot.cpp b/src/AllPlot.cpp index 7538577af..3bfb1a90a 100644 --- a/src/AllPlot.cpp +++ b/src/AllPlot.cpp @@ -676,7 +676,10 @@ AllPlot::setXTitle() void AllPlot::setDataFromPlot(AllPlot *plot, int startidx, int stopidx) { - if (plot == NULL) return; + if (plot == NULL) { + rideItem = NULL; + return; + } referencePlot = plot; diff --git a/src/AllPlotWindow.cpp b/src/AllPlotWindow.cpp index fa36ae670..146d9a52f 100644 --- a/src/AllPlotWindow.cpp +++ b/src/AllPlotWindow.cpp @@ -353,6 +353,7 @@ AllPlotWindow::AllPlotWindow(MainWindow *mainWindow) : connect(mainWindow, SIGNAL(intervalSelected()), this, SLOT(intervalSelected())); connect(mainWindow, SIGNAL(configChanged()), allPlot, SLOT(configChanged())); connect(mainWindow, SIGNAL(configChanged()), this, SLOT(configChanged())); + connect(mainWindow, SIGNAL(rideDeleted(RideItem*)), this, SLOT(rideDeleted(RideItem*))); } void @@ -551,6 +552,20 @@ AllPlotWindow::rideSelected() stale = false; } +void +AllPlotWindow::rideDeleted(RideItem *ride) +{ + if (ride == myRideItem) { + // we have nothing to show + setProperty("ride", QVariant::fromValue(NULL)); + + // notify all the plots, because when zones are redrawn + // they will try and reference AllPlot::rideItem + setAllPlotWidgets(NULL); + fullPlot->setDataFromRide(NULL); + } +} + void AllPlotWindow::zonesChanged() { diff --git a/src/AllPlotWindow.h b/src/AllPlotWindow.h index 93a1357b4..6e45b7879 100644 --- a/src/AllPlotWindow.h +++ b/src/AllPlotWindow.h @@ -87,6 +87,7 @@ class AllPlotWindow : public GcWindow // trap GC signals void rideSelected(); + void rideDeleted(RideItem *ride); void intervalSelected(); void zonesChanged(); void intervalsChanged();