]> err.no Git - mapper/commitdiff
Always run gtk mainloop in sqlite cb.
authorKaj-Michael Lang <milang@onion.tal.org>
Fri, 29 Feb 2008 14:12:43 +0000 (16:12 +0200)
committerKaj-Michael Lang <milang@onion.tal.org>
Fri, 29 Feb 2008 14:12:43 +0000 (16:12 +0200)
src/mapper.c
src/osm-db.c
src/osm-db.h

index 84bbae47a89ab2084772900241f725cc88aa0328..b84a8c90dcde9c19d72df5975eb55fc4ae2b242a 100644 (file)
@@ -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";
index 25f7d49c6ca853623e79389efda8ff908e01475b..dbadff3a34807eb024d94e8b1a7c10417ae30a29 100644 (file)
@@ -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 *
index 2ef777d6c5b88fc65a604b6322c7adcf950f8cd2..d7c836972f1fc015f53bc15578a08bb7431ee445 100644 (file)
@@ -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);