diff options
-rw-r--r-- | navit/gui/internal/gui_internal.c | 17 | ||||
-rw-r--r-- | navit/navit.c | 26 | ||||
-rw-r--r-- | navit/navit.h | 1 |
3 files changed, 30 insertions, 14 deletions
diff --git a/navit/gui/internal/gui_internal.c b/navit/gui/internal/gui_internal.c index 908b2756f..0a62ae010 100644 --- a/navit/gui/internal/gui_internal.c +++ b/navit/gui/internal/gui_internal.c @@ -2042,6 +2042,7 @@ gui_internal_cmd_set_active_profile(struct gui_priv *this, struct struct attr vehicle_name_attr; char *vehicle_name = NULL; struct attr profilename_attr; + struct attr vehicle; // Get the vehicle name vehicle_get_attr(v, attr_name, &vehicle_name_attr, NULL); @@ -2057,15 +2058,23 @@ gui_internal_cmd_set_active_profile(struct gui_priv *this, struct dbg(lvl_error, "Unable to set the vehicle's profile name\n"); } + navit_set_vehicleprofile_name(this->nav,profilename); + + save_vehicle_xml(v); + // Notify Navit that the routing should be re-done if this is the // active vehicle. if (gui_internal_is_active_vehicle(this, v)) { - struct attr vehicle; - vehicle.type=attr_vehicle; vehicle.u.vehicle=v; - navit_set_attr(this->nav, &vehicle); } - save_vehicle_xml(v); + else { + + vehicle.u.vehicle=NULL; + } + + vehicle.type=attr_vehicle; + navit_set_attr(this->nav, &vehicle); + gui_internal_prune_menu_count(this, 1, 0); gui_internal_menu_vehicle_settings(this, v, vehicle_name); diff --git a/navit/navit.c b/navit/navit.c index 3f4678032..42fb74dab 100644 --- a/navit/navit.c +++ b/navit/navit.c @@ -3269,7 +3269,7 @@ navit_set_vehicleprofile(struct navit *this_, struct vehicleprofile *vp) return 1; } -static int +int navit_set_vehicleprofile_name(struct navit *this_, char *name) { struct attr attr; @@ -3296,17 +3296,23 @@ navit_set_vehicle(struct navit *this_, struct navit_vehicle *nv) if (navit_set_vehicleprofile_name(this_, attr.u.str)) return; } - if (!navit_set_vehicleprofile_name(this_,"car")) { - /* We do not have a fallback "car" profile - * so lets set any profile */ - GList *l; - l=this_->vehicleprofiles; - if (l) { - this_->vehicleprofile=l->data; - if (this_->route) - route_set_profile(this_->route, this_->vehicleprofile); + if (!this_->vehicleprofile) { // When deactivating vehicle, keep the last profile if any + if (!navit_set_vehicleprofile_name(this_,"car")) { + /* We do not have a fallback "car" profile + * so lets set any profile */ + GList *l; + l=this_->vehicleprofiles; + if (l) { + this_->vehicleprofile=l->data; + if (this_->route) + route_set_profile(this_->route, this_->vehicleprofile); + } } } + else { + if (this_->route) + route_set_profile(this_->route, this_->vehicleprofile); + } } /** diff --git a/navit/navit.h b/navit/navit.h index e8cc29078..898ff6cff 100644 --- a/navit/navit.h +++ b/navit/navit.h @@ -117,6 +117,7 @@ struct navigation *navit_get_navigation(struct navit *this_); struct displaylist *navit_get_displaylist(struct navit *this_); void navit_layout_switch(struct navit *n); int navit_set_vehicle_by_name(struct navit *n, const char *name); +int navit_set_vehicleprofile_name(struct navit *this_, char *name); int navit_set_layout_by_name(struct navit *n, const char *name); void navit_disable_suspend(void); int navit_block(struct navit *this_, int block); |