diff options
| -rw-r--r-- | navit/event.c | 27 | ||||
| -rw-r--r-- | navit/graphics.c | 5 |
2 files changed, 27 insertions, 5 deletions
diff --git a/navit/event.c b/navit/event.c index 550aa7fd6..96d2e0dd8 100644 --- a/navit/event.c +++ b/navit/event.c @@ -29,12 +29,24 @@ static const char *e_system; static int has_quit; +#define require_method_helper(m)\ + if(!event_methods.m) {\ + dbg(lvl_error, "Can't find event system method %s. Event system is %s%s\n",\ + #m ,e_system?"set to ":"not set.", e_system?e_system:"");\ + +#define require_method(m)\ + require_method_helper(m)\ + return;\ + } + +#define require_method2(m,r)\ + require_method_helper(m)\ + return r;\ + } + void event_main_loop_run(void) { - if (! event_methods.main_loop_run) { - dbg(lvl_error,"no event system set\n"); - return; - } + require_method(main_loop_run); event_methods.main_loop_run(); } @@ -54,42 +66,49 @@ event_main_loop_has_quit(void) struct event_watch * event_add_watch(int fd, enum event_watch_cond cond, struct callback *cb) { + require_method2(add_watch, NULL); return event_methods.add_watch(fd, cond, cb); } void event_remove_watch(struct event_watch *ev) { + require_method(remove_watch); event_methods.remove_watch(ev); } struct event_timeout * event_add_timeout(int timeout, int multi, struct callback *cb) { + require_method2(add_timeout, NULL); return event_methods.add_timeout(timeout, multi, cb); } void event_remove_timeout(struct event_timeout *ev) { + require_method(remove_timeout); event_methods.remove_timeout(ev); } struct event_idle * event_add_idle(int priority, struct callback *cb) { + require_method2(add_idle, NULL); return event_methods.add_idle(priority,cb); } void event_remove_idle(struct event_idle *ev) { + require_method(remove_idle); event_methods.remove_idle(ev); } void event_call_callback(struct callback_list *cb) { + require_method(call_callback); event_methods.call_callback(cb); } diff --git a/navit/graphics.c b/navit/graphics.c index 53a1984ad..2858de828 100644 --- a/navit/graphics.c +++ b/navit/graphics.c @@ -232,12 +232,15 @@ struct graphics * graphics_new(struct attr *parent, struct attr **attrs) struct graphics_priv * (*graphicstype_new)(struct navit *nav, struct graphics_methods *meth, struct attr **attrs, struct callback_list *cbl); if (! (type_attr=attr_search(attrs, NULL, attr_type))) { + dbg(lvl_error,"Graphics plugin type is not set.\n"); return NULL; } graphicstype_new=plugin_get_graphics_type(type_attr->u.str); - if (! graphicstype_new) + if (! graphicstype_new) { + dbg(lvl_error,"Failed to load graphics plugin %s.\n", type_attr->u.str); return NULL; + } this_=g_new0(struct graphics, 1); this_->attrs=attr_list_dup(attrs); this_->cbl=callback_list_new(); |
