From f274cb9761c09f374c3437a4d47cbf681f28121e Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Fri, 29 Feb 2008 16:12:43 +0200 Subject: [PATCH] Always run gtk mainloop in sqlite cb. --- src/mapper.c | 4 +++- src/osm-db.c | 20 ++++++++++++++++---- src/osm-db.h | 1 + 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/mapper.c b/src/mapper.c index 84bbae4..b84a8c9 100644 --- a/src/mapper.c +++ b/src/mapper.c @@ -213,6 +213,7 @@ audio_note_deinit(); gps_disconnect(_gps); gps_free(_gps); +osm_db_enable_mainloop(_db, FALSE); osm_deinit(); db_close(&_db); track_deinit(); @@ -329,7 +330,8 @@ switch (mis) { w="POIs"; break; case MAPPER_INIT_OSM: - osm_init(&_db); + if (osm_init(&_db)) + osm_db_enable_mainloop(_db, TRUE); mis=MAPPER_INIT_VOICE; p=0.8; w="OSM"; diff --git a/src/osm-db.c b/src/osm-db.c index 25f7d49..dbadff3 100644 --- a/src/osm-db.c +++ b/src/osm-db.c @@ -116,7 +116,13 @@ return TRUE; static int osm_progress(void *ud) { +g_debug("SQL: Running gtk mainloop"); +#if 1 +while (gtk_events_pending()) + gtk_main_iteration(); +#else gtk_main_iteration_do(FALSE); +#endif return 0; } @@ -127,7 +133,6 @@ if (!dbpw) return; gtk_progress_bar_set_text(dbpw, ""); gtk_progress_bar_set_fraction(dbpw, 0.0); -sqlite3_progress_handler(db, OSM_DB_PROGRESS_NUM, NULL, NULL); } static void @@ -138,7 +143,6 @@ if (!dbpw) gtk_progress_bar_set_text(dbpw, _("Searching...")); gtk_progress_bar_pulse(dbpw); gtk_main_iteration_do(FALSE); -sqlite3_progress_handler(db, OSM_DB_PROGRESS_NUM, osm_progress, NULL); } void @@ -301,14 +305,22 @@ if (!db || !*db) { osmdb=*db; memset(&sql, 0, sizeof(sql)); if (osm_db_prepare(osmdb)==FALSE) { - g_printerr("Failed to prepare OSM SQL statements:"); - g_printf("SQLITE: %s\n", sqlite3_errmsg(osmdb)); + g_printerr("Failed to prepare OSM SQL statements: %s", sqlite3_errmsg(osmdb)); return FALSE; } osm_db_ok=TRUE; return TRUE; } +void +osm_db_enable_mainloop(sqlite3 *db, gboolean eml) +{ +if (eml==FALSE) + sqlite3_progress_handler(db, OSM_DB_PROGRESS_NUM, NULL, NULL); +else + sqlite3_progress_handler(db, OSM_DB_PROGRESS_NUM, osm_progress, NULL); +} + /*****************************************************************************/ osm_way_node * diff --git a/src/osm-db.h b/src/osm-db.h index 2ef777d..d7c8369 100644 --- a/src/osm-db.h +++ b/src/osm-db.h @@ -57,6 +57,7 @@ void osm_set_way_range(guint sr); gboolean osm_way_search(gdouble lat, gdouble lon, gchar *text, GtkListStore **store); +void osm_db_enable_mainloop(sqlite3 *db, gboolean eml); void osm_progress_set_widget(sqlite3 *db, GtkProgressBar *w); gboolean osm_db_prepare(sqlite3 *db); -- 2.39.5