mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
Fix first file SEGV
If you delete and readd an activity after showing it on the diary view you get a SEGV. This is an edge case related to deleting the last activity and going back to the blank state before importing another. Actually there are 3 technical issues; 1. GcCalendar doesn't get notified by MainWindow when there are no rides -- so it crashes on refresh 2. RideSummaryWindow doesn't get notified by home window if its not visible 3. RideSummaryWindow should check rideItem isn't NULL before trying to plot zones (but only for date range summaries) Fixes #622
This commit is contained in:
@@ -951,6 +951,13 @@ GcMultiCalendar::setRide(RideItem *ride)
|
||||
if (active) return;
|
||||
if (!isVisible()) {
|
||||
stale = true;
|
||||
|
||||
// notify of ride gone though as not repeated
|
||||
if (!_ride) {
|
||||
for (int i=0; i<showing; i++) {
|
||||
calendars.at(i)->setRide(_ride); // current ride is on this one
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -239,7 +239,8 @@ HomeWindow::titleChanged()
|
||||
void
|
||||
HomeWindow::rideSelected()
|
||||
{
|
||||
if (amVisible()) {
|
||||
// we need to notify of null rides immediately
|
||||
if (!myRideItem || amVisible()) {
|
||||
for (int i=0; i < charts.count(); i++) {
|
||||
|
||||
// show if its not a tab
|
||||
|
||||
@@ -1249,13 +1249,13 @@ MainWindow::rideTreeWidgetSelectionChanged()
|
||||
// update the ride property on all widgets
|
||||
// to let them know they need to replot new
|
||||
// selected ride
|
||||
gcCalendar->setRide(ride);
|
||||
gcMultiCalendar->setRide(ride);
|
||||
_rideMetadata->setProperty("ride", QVariant::fromValue<RideItem*>(dynamic_cast<RideItem*>(ride)));
|
||||
analWindow->setProperty("ride", QVariant::fromValue<RideItem*>(dynamic_cast<RideItem*>(ride)));
|
||||
homeWindow->setProperty("ride", QVariant::fromValue<RideItem*>(dynamic_cast<RideItem*>(ride)));
|
||||
diaryWindow->setProperty("ride", QVariant::fromValue<RideItem*>(dynamic_cast<RideItem*>(ride)));
|
||||
trainWindow->setProperty("ride", QVariant::fromValue<RideItem*>(dynamic_cast<RideItem*>(ride)));
|
||||
gcCalendar->setRide(ride);
|
||||
gcMultiCalendar->setRide(ride);
|
||||
|
||||
if (!ride) return;
|
||||
|
||||
@@ -1990,6 +1990,8 @@ MainWindow::removeCurrentRide()
|
||||
if (allRides->childCount() == 0) {
|
||||
ride = NULL;
|
||||
rideTreeWidgetSelectionChanged(); // notifies children
|
||||
gcCalendar->setRide(ride); // and the pesky calendars
|
||||
gcMultiCalendar->setRide(ride);
|
||||
}
|
||||
|
||||
treeWidget->setCurrentItem(itemToSelect);
|
||||
|
||||
@@ -186,7 +186,7 @@ RideSummaryWindow::htmlSummary() const
|
||||
RideFile *ride;
|
||||
|
||||
if (!rideItem && !ridesummary) return ""; // nothing selected!
|
||||
else ride = rideItem->ride();
|
||||
else ride = rideItem ? rideItem->ride() : NULL;
|
||||
|
||||
if (!ride && !ridesummary) return ""; // didn't parse!
|
||||
|
||||
@@ -381,7 +381,7 @@ RideSummaryWindow::htmlSummary() const
|
||||
//
|
||||
// Time In Zones
|
||||
//
|
||||
if (rideItem->numZones() > 0) {
|
||||
if (rideItem && rideItem->numZones() > 0) {
|
||||
QVector<double> time_in_zone(rideItem->numZones());
|
||||
for (int i = 0; i < rideItem->numZones(); ++i) {
|
||||
|
||||
@@ -396,7 +396,7 @@ RideSummaryWindow::htmlSummary() const
|
||||
//
|
||||
// Time In Zones HR
|
||||
//
|
||||
if (rideItem->numHrZones() > 0) {
|
||||
if (rideItem && rideItem->numHrZones() > 0) {
|
||||
QVector<double> time_in_zone(rideItem->numHrZones());
|
||||
for (int i = 0; i < rideItem->numHrZones(); ++i) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user