TrainRoutePlanner::~TrainRoutePlanner()
{
- delete thread;
+ if(thread)
+ {
+ thread->join();
+ delete thread;
+ }
}
TrainRoutePlanner::Result TrainRoutePlanner::plan()
{
if(result==PENDING && goal)
{
+ if(thread)
+ {
+ thread->join();
+ delete thread;
+ thread = 0;
+ }
finalize_plan();
- delete thread;
- thread = 0;
}
return result;
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; i<waypoints.size(); ++i)
+ if(destination)
{
- waypoints[i] = &router->get_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; i<waypoints.size(); ++i)
+ {
+ waypoints[i] = &router->get_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