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:
Mark Liversedge
2013-05-30 19:31:26 +01:00
parent 3c62ac98b4
commit 894cbcc4e7
4 changed files with 16 additions and 6 deletions

View File

@@ -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);