From: Mikko Rasa Date: Thu, 5 Feb 2015 13:53:32 +0000 (+0200) Subject: Don't access waypoint and metric data if the router has no destination X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=c650f1106f3e8ee1966dcbc821128cdbbb1b378c;p=r2c2.git Don't access waypoint and metric data if the router has no destination --- diff --git a/source/libr2c2/trainrouteplanner.cpp b/source/libr2c2/trainrouteplanner.cpp index dbe6035..0d0103c 100644 --- a/source/libr2c2/trainrouteplanner.cpp +++ b/source/libr2c2/trainrouteplanner.cpp @@ -213,15 +213,18 @@ TrainRoutePlanner::TrainRoutingInfo::TrainRoutingInfo(Train &t): if(router) { destination = router->get_destination(); - waypoints.resize(router->get_n_waypoints()); - metrics.resize(waypoints.size()+1); - metrics[0] = &router->get_metric(-1); - for(unsigned i=0; iget_waypoint(i); - metrics[i+1] = &router->get_metric(i); + waypoints.resize(router->get_n_waypoints()); + metrics.resize(waypoints.size()+1); + metrics[0] = &router->get_metric(-1); + for(unsigned i=0; iget_waypoint(i); + metrics[i+1] = &router->get_metric(i); + } + has_duration = router->get_trip_duration(); } - has_duration = router->get_trip_duration(); } // If no maximum speed is specified, use a sensible default