From: Paul Ramsey Date: Tue, 26 Mar 2013 13:12:54 +0000 (+0000) Subject: #2186, gui progress bar update is slowing loads X-Git-Tag: 2.1.0beta2~142 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=838096c92ddc1100e0414542192ebf5edca1da61;p=postgis #2186, gui progress bar update is slowing loads git-svn-id: http://svn.osgeo.org/postgis/trunk@11209 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/loader/shp2pgsql-gui.c b/loader/shp2pgsql-gui.c index 20308ad37..13b46f3e0 100644 --- a/loader/shp2pgsql-gui.c +++ b/loader/shp2pgsql-gui.c @@ -1578,6 +1578,12 @@ pgui_action_import(GtkWidget *widget, gpointer data) /* If we are in prepare mode, we need to skip the actual load. */ if (state->config->opt != 'p') { + int numrecords = ShpLoaderGetRecordCount(state); + int records_per_tick = (numrecords / 200) - 1; + + if ( records_per_tick < 1 ) + records_per_tick = 1; + /* If we are in COPY (dump format) mode, output the COPY statement and enter COPY mode */ if (state->config->dump_format) { @@ -1600,7 +1606,7 @@ pgui_action_import(GtkWidget *widget, gpointer data) } /* Main loop: iterate through all of the records and send them to stdout */ - for (i = 0; i < ShpLoaderGetRecordCount(state) && is_running; i++) + for (i = 0; i < numrecords && is_running; i++) { ret = ShpLoaderGenerateSQLRowStatement(state, i, &record); @@ -1652,7 +1658,8 @@ pgui_action_import(GtkWidget *widget, gpointer data) } /* Update the progress bar */ - gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress), (float)i / ShpLoaderGetRecordCount(state)); + if ( i % records_per_tick == 0 ) + gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress), (float)i / numrecords); /* Allow GTK events to get a look in */ while (gtk_events_pending())