From: Kaj-Michael Lang Date: Wed, 27 Feb 2008 16:59:57 +0000 (+0200) Subject: Use a timeout to pulse the progress bar and just run the mainloop in the sqlite progr... X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d634e9cb9a5af0d1c3a405281a1c8b31eea94378;p=mapper Use a timeout to pulse the progress bar and just run the mainloop in the sqlite progress callback. --- diff --git a/src/osm-db.c b/src/osm-db.c index 86124cd..25f7d49 100644 --- a/src/osm-db.c +++ b/src/osm-db.c @@ -39,7 +39,7 @@ /* #define DEBUG_OSM_TIME */ #define OSM_PLACE_CACHE_MAX_ITEMS (64) -#define OSM_DB_PROGRESS_NUM (20000) +#define OSM_DB_PROGRESS_NUM (15000) /* Node search ranges */ #define OSM_RANGE_START (16384) @@ -80,6 +80,7 @@ struct osm_place_cache { static struct osm_place_cache pcache; static guint way_dist_range=OSM_RANGE_WAY; +static gint sid=0; osm_way_node *osm_way_get_prev_node(osm_way *w); osm_way_node *osm_way_get_next_node(osm_way *w); @@ -103,12 +104,18 @@ else /*****************************************************************************/ -static int -osm_progress(void *ud) +static gboolean +osm_progress_pulse(void) { if (!dbpw) - return 0; + return FALSE; gtk_progress_bar_pulse(dbpw); +return TRUE; +} + +static int +osm_progress(void *ud) +{ gtk_main_iteration_do(FALSE); return 0; } @@ -129,17 +136,27 @@ osm_progress_show(sqlite3 *db) if (!dbpw) return; 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 osm_progress_set_widget(sqlite3 *db, GtkProgressBar *w) { -if (dbpw!=NULL && w==NULL) +if (dbpw!=NULL && w==NULL) { osm_progress_hide(db); + if (sid!=0) + g_source_remove(sid); + sid=0; + dbpw=NULL; + return; +} dbpw=w; -if (w!=NULL) +if (w!=NULL) { osm_progress_show(db); + sid=g_timeout_add(200, osm_progress_pulse, NULL); +} } /*****************************************************************************/