// Check if we've reached the next route
if(routes.size()>1)
{
- const Route &route = **++routes.begin();
- if(route.has_track(*b_iter.endpoint().track))
+ Track &track = *b_iter.endpoint().track;
+ const Route *route = get_route();
+ bool change_route = false;
+ if(route->is_loop())
+ change_route = (*++routes.begin())->has_track(track);
+ else
+ change_route = !route->has_track(track);
+
+ if(change_route)
{
routes.pop_front();
- const Route *r = get_route();
+ route = get_route();
// XXX Exceptions?
- signal_route_changed.emit(r);
- signal_event.emit(Message("route-changed", r));
+ signal_route_changed.emit(route);
+ signal_event.emit(Message("route-changed", route));
}
}