Improved diagnostics for graphics/gui problems
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sun, 4 Nov 2007 10:04:47 +0000 (10:04 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sun, 4 Nov 2007 10:04:47 +0000 (10:04 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@510 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/src/navit.c
navit/src/navit.h
navit/src/xmlconfig.c

index 36f7d63..ccc5829 100644 (file)
@@ -50,8 +50,10 @@ struct navit {
        GList *mapsets;
        GList *layouts;
        struct gui *gui;
+       char *gui_type;
        struct layout *layout_current;
        struct graphics *gra;
+       char *gra_type;
        struct action *action;
        struct transformation *trans;
        struct compass *compass;
@@ -212,9 +214,10 @@ navit_new(struct coord *center, enum projection pro, int zoom)
 }
 
 void
-navit_set_gui(struct navit *this_, struct gui *gui)
+navit_set_gui(struct navit *this_, struct gui *gui, char *type)
 {
        this_->gui=gui;
+       this_->gui_type=g_strdup(type);
        if (gui_has_main_loop(this_->gui)) {
                if (! main_loop_gui) {
                        main_loop_gui=this_->gui;
@@ -229,9 +232,10 @@ navit_set_gui(struct navit *this_, struct gui *gui)
 }
 
 void
-navit_set_graphics(struct navit *this_, struct graphics *gra)
+navit_set_graphics(struct navit *this_, struct graphics *gra, char *type)
 {
        this_->gra=gra;
+       this_->gra_type=g_strdup(type);
        graphics_register_resize_callback(this_->gra, navit_resize, this_);
        graphics_register_button_callback(this_->gra, navit_button, this_);
 }
@@ -780,8 +784,18 @@ navit_init(struct navit *this_)
        GList *l;
        struct navit_vehicle *nv;
 
-       if (!this_->gui || !this_->gra || gui_set_graphics(this_->gui, this_->gra)) {
-               g_warning("failed to connect graphics to gui\n");
+       if (!this_->gui) {
+               g_warning("failed to instantiate gui '%s'\n",this_->gui_type);
+               navit_destroy(this_);
+               return;
+       }
+       if (!this_->gra) {
+               g_warning("failed to instantiate gui '%s'\n",this_->gra_type);
+               navit_destroy(this_);
+               return;
+       }
+       if (gui_set_graphics(this_->gui, this_->gra)) {
+               g_warning("failed to connect graphics '%s' to gui '%s'\n", this_->gra_type, this_->gui_type);
                g_warning(" Please see http://navit.sourceforge.net/wiki/index.php/Failed_to_connect_graphics_to_gui\n");
                g_warning(" for explanations and solutions\n");
 
index beb6de1..325812a 100644 (file)
@@ -29,15 +29,16 @@ struct transformation;
 struct vehicle;
 void navit_add_mapset(struct navit *this_, struct mapset *ms);
 struct mapset *navit_get_mapset(struct navit *this_);
+struct tracking *navit_get_tracking(struct navit *this_);
 void navit_add_layout(struct navit *this_, struct layout *lay);
 void navit_draw(struct navit *this_);
 void navit_draw_displaylist(struct navit *this_);
 void navit_zoom_in(struct navit *this_, int factor);
 void navit_zoom_out(struct navit *this_, int factor);
 struct navit *navit_new(struct coord *center, enum projection pro, int zoom);
-void navit_set_gui(struct navit *this_, struct gui *gui);
-void navit_set_graphics(struct navit *this_, struct graphics *gra);
-struct graphics * navit_get_graphics(struct navit *this_);
+void navit_set_gui(struct navit *this_, struct gui *gui, char *type);
+void navit_set_graphics(struct navit *this_, struct graphics *gra, char *type);
+struct graphics *navit_get_graphics(struct navit *this_);
 void navit_set_destination(struct navit *this_, struct coord *c, char *description);
 void navit_add_bookmark(struct navit *this_, struct coord *c, char *description);
 void navit_add_menu_layouts(struct navit *this_, struct menu *men);
@@ -70,7 +71,6 @@ void navit_add_init_cb(struct navit *this_, struct callback *cb);
 void navit_remove_init_cb(struct navit *this_, struct callback *cb);
 void navit_set_vehicle(struct navit *this_, struct navit_vehicle *nv);
 void navit_tracking_add(struct navit *this_, struct tracking *tracking);
-struct tracking * navit_get_tracking(struct navit *this_);
 void navit_route_add(struct navit *this_, struct route *route);
 void navit_navigation_add(struct navit *this_, struct navigation *navigation);
 void navit_set_speech(struct navit *this_, struct speech *speech);
index bf5ceb4..74d2ce6 100644 (file)
@@ -223,7 +223,7 @@ xmlconfig_graphics(struct xmlstate *state)
        state->element_object = graphics_new(type, attrs);
        if (! state->element_object)
                return 0;
-       navit_set_graphics(state->parent->element_object, state->element_object);
+       navit_set_graphics(state->parent->element_object, state->element_object, type);
        return 1;
 }
 
@@ -238,7 +238,7 @@ xmlconfig_gui(struct xmlstate *state)
        state->element_object = gui_new(state->parent->element_object, type, attrs);
        if (! state->element_object)
                return 0;
-       navit_set_gui(state->parent->element_object, state->element_object);
+       navit_set_gui(state->parent->element_object, state->element_object, type);
        return 1;
 }