diff --git a/src/AllPlotWindow.cpp b/src/AllPlotWindow.cpp index e566a4d09..83ef0e783 100644 --- a/src/AllPlotWindow.cpp +++ b/src/AllPlotWindow.cpp @@ -494,6 +494,8 @@ AllPlotWindow::rideSelected() { RideItem *ride = myRideItem; + if (ride == NULL) current = NULL; + // ignore if not active if (!amVisible()) { stale = true; @@ -501,7 +503,10 @@ AllPlotWindow::rideSelected() } // ignore if null, or manual / empty - if (!ride || !ride->ride() || !ride->ride()->dataPoints().count()) return; + if (!ride || !ride->ride() || !ride->ride()->dataPoints().count()) { + current = NULL; + return; + } // we already plotted it! if (ride == current && stale == false) return; @@ -1005,6 +1010,8 @@ AllPlotWindow::hideSelection() void AllPlotWindow::setShowPower(int value) { + if (!current) return; + // we only show the power shading on the // allPlot / stack plots, not on the fullPlot allPlot->showPower(value); @@ -1027,6 +1034,8 @@ AllPlotWindow::setShowPower(int value) void AllPlotWindow::setShowHr(int value) { + if (!current) return; + allPlot->showHr(value); foreach (AllPlot *plot, allPlots) plot->showHr(value); @@ -1035,6 +1044,8 @@ AllPlotWindow::setShowHr(int value) void AllPlotWindow::setShowSpeed(int value) { + if (!current) return; + allPlot->showSpeed(value); foreach (AllPlot *plot, allPlots) plot->showSpeed(value); @@ -1043,6 +1054,8 @@ AllPlotWindow::setShowSpeed(int value) void AllPlotWindow::setShowCad(int value) { + if (!current) return; + allPlot->showCad(value); foreach (AllPlot *plot, allPlots) plot->showCad(value); @@ -1051,6 +1064,8 @@ AllPlotWindow::setShowCad(int value) void AllPlotWindow::setShowAlt(int value) { + if (!current) return; + allPlot->showAlt(value); foreach (AllPlot *plot, allPlots) plot->showAlt(value); @@ -1059,6 +1074,8 @@ AllPlotWindow::setShowAlt(int value) void AllPlotWindow::setShowGrid(int value) { + if (!current) return; + allPlot->showGrid(value); foreach (AllPlot *plot, allPlots) plot->showGrid(value); @@ -1067,6 +1084,8 @@ AllPlotWindow::setShowGrid(int value) void AllPlotWindow::setByDistance(int value) { + if (!current) return; + fullPlot->setByDistance(value); allPlot->setByDistance(value); @@ -1082,6 +1101,8 @@ AllPlotWindow::setByDistance(int value) void AllPlotWindow::setSmoothing(int value) { + if (!current) return; + // recalculate etc fullPlot->setSmoothing(value); @@ -1097,6 +1118,8 @@ AllPlotWindow::setSmoothing(int value) void AllPlotWindow::resetStackedDatas() { + if (!current) return; + int _stackWidth = stackWidth; if (allPlot->bydist) _stackWidth = stackWidth/3; @@ -1164,6 +1187,8 @@ AllPlotWindow::setStackZoomUp() void AllPlotWindow::setStackZoomDown() { + if (!current) return; + if (stackWidth>4) { stackWidth = floor(stackWidth / 1.25); diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 665e69587..fda7c91af 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -897,6 +897,12 @@ MainWindow::removeCurrentRide() rideDeleted(item); delete item; + // any left? + if (allRides->childCount() == 0) { + ride = NULL; + rideTreeWidgetSelectionChanged(); // notifies children + } + // added djconnel: remove old cpi file, then update bests which are associated with the file criticalPowerWindow->deleteCpiFile(strOldFileName); diff --git a/src/RideEditor.cpp b/src/RideEditor.cpp index 0b67f0800..69264fb1d 100644 --- a/src/RideEditor.cpp +++ b/src/RideEditor.cpp @@ -281,11 +281,11 @@ RideEditor::find() // look for a value in a range and allow user to next/previous across //RideEditorFindDialog finder(this, table); //finder.exec(); - FindDialog *finder = new FindDialog(this); + //FindDialog *finder = new FindDialog(this); // clear when a new ride is selected - connect(main, SIGNAL(rideSelected()), finder, SLOT(clear())); - finder->show(); + //connect(main, SIGNAL(rideSelected()), finder, SLOT(clear())); + //finder->show(); } void @@ -1084,6 +1084,11 @@ RideEditor::rideSelected() RideItem *current = myRideItem; if (!current || !current->ride()) { model->setRide(NULL); + if (data) { + delete data; + data = NULL; + } + findTool->rideSelected(); return; } @@ -1605,6 +1610,8 @@ FindDialog::typeChanged(int index) void FindDialog::find() { + if (rideEditor->data == NULL) return; + // are we looking anywhere? bool search = false; foreach (QCheckBox *c, channels) if (c->isChecked()) search = true; @@ -1746,10 +1753,11 @@ FindDialog::dataChanged() void FindDialog::clear() { - rideEditor->data->found.clear(); - clearResultsTable(); - rideEditor->model->forceRedraw(); - + if (rideEditor->data) { + rideEditor->data->found.clear(); + clearResultsTable(); + rideEditor->model->forceRedraw(); + } } void diff --git a/src/RideFileTableModel.cpp b/src/RideFileTableModel.cpp index 8bfe39dd0..fd8ed50dc 100644 --- a/src/RideFileTableModel.cpp +++ b/src/RideFileTableModel.cpp @@ -277,7 +277,8 @@ void RideFileTableModel::forceRedraw() { // tell the view to redraw everything - dataChanged(createIndex(0,0), createIndex(headingsType.count(), ride->dataPoints().count())); + if (ride) + dataChanged(createIndex(0,0), createIndex(headingsType.count(), ride->dataPoints().count())); } //