EXTRA_DIST = navit.xml
navit_SOURCES = attr.c callback.c compass.c coord.c country.c cursor.c data_window.c debug.c \
- file.c graphics.c gui.c item.c layout.c log.c main.c map.c \
+ event.c file.c graphics.c gui.c item.c layout.c log.c main.c map.c \
mapset.c maptype.c menu.c navit.c navigation.c osd.c param.c phrase.c plugin.c popup.c \
profile.c projection.c route.c search.c speech.c transform.c track.c \
util.c vehicle.c xmlconfig.c attr.h attr_def.h callback.h color.h compass.h coord.h country.h \
#include "debug.h"
-int debug_level=0;
+int debug_level=0,segv_level=0;
static GHashTable *debug_hash;
+static char *gdb_program;
-#if 0
static void sigsegv(int sig)
{
- FILE *f;
- time_t t;
- printf("segmentation fault received\n");
- f=fopen("crash.txt","a");
- setvbuf(f, NULL, _IONBF, 0);
- fprintf(f,"segmentation fault received\n");
- t=time(NULL);
- fprintf(f,"Time: %s", ctime(&t));
- file_unmap_all();
- fprintf(f,"dumping core\n");
- fclose(f);
- abort();
+ char buffer[256];
+ if (segv_level > 1)
+ sprintf(buffer, "gdb -ex bt %s %d", gdb_program, getpid());
+ else
+ sprintf(buffer, "gdb -ex bt -ex detach -ex quit %s %d", gdb_program, getpid());
+ system(buffer);
+ exit(1);
}
-#endif
void
-debug_init(void)
+debug_init(const char *program_name)
{
-#if 0
+ gdb_program=program_name;
signal(SIGSEGV, sigsegv);
-#endif
debug_hash=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
}
debug_level_set(const char *name, int level)
{
debug_level=0;
- g_hash_table_insert(debug_hash, g_strdup(name), (gpointer) level);
- g_hash_table_foreach(debug_hash, debug_update_level, NULL);
+ if (strcmp(name,"segv")) {
+ g_hash_table_insert(debug_hash, g_strdup(name), (gpointer) level);
+ g_hash_table_foreach(debug_hash, debug_update_level, NULL);
+ } else {
+ segv_level=level;
+ if (segv_level)
+ signal(SIGSEGV, sigsegv);
+ else
+ signal(SIGSEGV, NULL);
+ }
}
int
#define dbg(level,fmt...) ({ if (debug_level >= level) debug_printf(level,dbg_module,strlen(dbg_module),__PRETTY_FUNCTION__, strlen(__PRETTY_FUNCTION__),1,fmt); })
/* prototypes */
-void debug_init(void);
+void debug_init(const char *program_name);
void debug_level_set(const char *name, int level);
int debug_level_get(const char *name);
void debug_vprintf(int level, const char *module, const int mlen, const char *function, const int flen, int prefix, const char *fmt, va_list ap);
--- /dev/null
+#include <glib.h>
+#include "event.h"
+
+static GMainLoop *loop;
+
+void event_main_loop_run(void)
+{
+ loop = g_main_loop_new (NULL, TRUE);
+ if (g_main_loop_is_running (loop))
+ {
+ g_main_loop_run (loop);
+ }
+}
+
+void event_main_loop_quit(void)
+{
+ if (loop)
+ g_main_loop_quit(loop);
+}
--- /dev/null
+void event_main_loop_run(void);
+void event_main_loop_quit(void);
#include <unistd.h>
#include <libintl.h>
-#ifdef USE_GTK_MAIN_LOOP
-#include <gtk/gtk.h>
-#endif
#include "config.h"
#include "file.h"
#include "debug.h"
#include "coord.h"
#include "route.h"
#include "navigation.h"
+#include "event.h"
#define _(STRING) gettext(STRING)
}
static GList *navit;
-#ifndef USE_GTK_MAIN_LOOP
-static GMainLoop *loop;
-#endif
struct iter {
GList *list;
main_remove_navit(struct navit *nav)
{
navit=g_list_remove(navit, nav);
- if (! navit) {
-#ifdef USE_GTK_MAIN_LOOP
- gtk_main_quit();
-#else
- if (loop)
- g_main_loop_quit(loop);
-#endif
- }
+ if (! navit)
+ event_main_loop_quit();
}
int main(int argc, char **argv)
setenv("LC_NUMERIC","C",1);
setlocale(LC_ALL,"");
setlocale(LC_NUMERIC,"C");
-
if (file_exists("navit.c") || file_exists("navit.o")) {
char buffer[PATH_MAX];
printf(_("Running from source directory\n"));
bind_textdomain_codeset (PACKAGE, "UTF-8");
textdomain(PACKAGE);
- debug_init();
+ debug_init(argv[0]);
if (getenv("LC_ALL"))
dbg(0,"Warning: LC_ALL is set, this might lead to problems\n");
#ifndef USE_PLUGINS
}
if (main_loop_gui) {
gui_run_main_loop(main_loop_gui);
- } else {
-#ifdef USE_GTK_MAIN_LOOP
- gtk_main();
-#else
- loop = g_main_loop_new (NULL, TRUE);
- if (g_main_loop_is_running (loop))
- {
- g_main_loop_run (loop);
- }
-#endif
- }
+ } else
+ event_main_loop_run();
return 0;
}
struct speech *this_;
struct speech_priv *(*speech_new)(const char *data, struct speech_methods *meth);
- dbg("enter type=%s data=%s\n", type, data);
+ dbg(1,"enter type=%s data=%s\n", type, data);
speech_new=plugin_get_speech_type(type);
dbg(1,"new=%p\n", speech_new);
if (! speech_new) {
return 0;
attrs=convert_to_attrs(state);
state->element_object = graphics_new(type, attrs);
- if (! state->element_object)
+ if (! state->element_object) {
+ dbg(0,"Failed to create graphics '%s'\n", type);
return 0;
+ }
navit_set_graphics(state->parent->element_object, state->element_object, type);
return 1;
}
return 0;
attrs=convert_to_attrs(state);
state->element_object = gui_new(state->parent->element_object, type, attrs);
- if (! state->element_object)
+ if (! state->element_object) {
+ dbg(0,"Failed to create gui '%s'\n", type);
return 0;
+ }
navit_set_gui(state->parent->element_object, state->element_object, type);
return 1;
}