Skip to content

Commit

Permalink
fix:core: Correct default layout handling. (#816)
Browse files Browse the repository at this point in the history
This commit corrects the default layout handling broken when splitting
the layouts to own files. It restores the layout saving of the internal
gui. So now it starts again with the last selected layout.
  • Loading branch information
metalstrolch committed Aug 7, 2019
1 parent 6bc6c0c commit ab4d808
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
4 changes: 0 additions & 4 deletions navit/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,6 @@ static void win_set_nls(void) {
}
#endif

void main_update_default_layout(struct navit *navit) {
navit_update_current_layout(navit, NULL);
}

void main_init(const char *program) {
char *s;
#ifdef _UNICODE /* currently for wince */
Expand Down
1 change: 0 additions & 1 deletion navit/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ void main_add_navit(struct navit *nav);
void main_remove_navit(struct navit *nav);
int main_add_attr(struct attr *attr);
int main_remove_attr(struct attr *attr);
void main_update_default_layout(struct navit *navit);
void main_init(const char *program);
void main_init_nls(void);
int main(int argc, char **argv);
Expand Down
22 changes: 21 additions & 1 deletion navit/navit.c
Original file line number Diff line number Diff line change
Expand Up @@ -2551,6 +2551,7 @@ static int navit_set_attr_do(struct navit *this_, struct attr *attr, int init) {
case attr_layout:
if(!attr->u.layout)
return 0;
dbg(lvl_debug,"setting attr_layout to %s", attr->u.layout->name);
if(this_->layout_current!=attr->u.layout) {
navit_update_current_layout(this_, attr->u.layout);
graphics_font_destroy_all(this_->gra);
Expand All @@ -2563,6 +2564,7 @@ static int navit_set_attr_do(struct navit *this_, struct attr *attr, int init) {
case attr_layout_name:
if(!attr->u.str)
return 0;
dbg(lvl_debug,"setting attr_layout_name to %s", attr->u.str);
l=this_->layouts;
while (l) {
lay=l->data;
Expand Down Expand Up @@ -3000,9 +3002,27 @@ static int navit_add_log(struct navit *this_, struct log *log) {

static int navit_add_layout(struct navit *this_, struct layout *layout) {
struct attr active;
int is_default=0;
int is_active=0;
this_->layouts = g_list_append(this_->layouts, layout);
/** check if we want to immediately activate this layout.
* Unfortunately we have concurring conditions about when to activate
* a layout:
* - A layout could bear the "active" property
* - A layout's name could match this_->default_layout_name
* This cannot be fully resolved, as we cannot predict the future, so
* lets set the last parsed layout active, which either matches default_layout_name or
* bears the "active" tag, or is the first layout ever parsed.
*/
if((layout->name != NULL) && (this_->default_layout_name != NULL)) {
if (strcmp(layout->name, this_->default_layout_name) == 0)
is_default = 1;
}
layout_get_attr(layout, attr_active, &active, NULL);
if(active.u.num || !this_->layout_current) {
if(active.u.num)
is_active = 1;
dbg(lvl_debug, "add layout '%s' is_default %d, is_active %d", layout->name, is_default, is_active);
if(is_default || is_active || !this_->layout_current) {
this_->layout_current=layout;
return 1;
}
Expand Down
1 change: 0 additions & 1 deletion navit/start_real.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ int main_real(int argc, char * const* argv) {
dbg(lvl_error, "%s", _("Internal initialization failed, exiting. Check previous error messages."));
exit(5);
}
main_update_default_layout(navit.u.navit);
conf.type=attr_config;
conf.u.config=config;
if (startup_file) {
Expand Down

0 comments on commit ab4d808

Please sign in to comment.