Fix:Core:Handle multiple calls to navigation_set_route correctly
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sun, 11 Dec 2011 23:15:37 +0000 (23:15 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sun, 11 Dec 2011 23:15:37 +0000 (23:15 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@4857 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/navigation.c

index 2288d43..8f44c3e 100644 (file)
@@ -2350,11 +2350,19 @@ void
 navigation_set_route(struct navigation *this_, struct route *route)
 {
        struct attr callback;
-       this_->route=route;
-       this_->route_cb=callback_new_attr_1(callback_cast(navigation_update), attr_route_status, this_);
+       if (!this_->route_cb)
+               this_->route_cb=callback_new_attr_1(callback_cast(navigation_update), attr_route_status, this_);
        callback.type=attr_callback;
        callback.u.callback=this_->route_cb;
-       route_add_attr(route, &callback);
+       if (this_->route)
+               route_remove_attr(this_->route, &callback);
+       this_->route=route;
+       if (this_->route) {
+               struct attr route_status;
+               route_add_attr(this_->route, &callback);
+               if (route_get_attr(this_->route, attr_route_status, &route_status, NULL))
+                       navigation_update(this_, this_->route, &route_status);
+       }
 }
 
 void