From: Mark Cave-Ayland Date: Sat, 4 Feb 2012 02:36:44 +0000 (+0000) Subject: Fix an issue in the shapefile GUI caused by saving the original shapefile name before... X-Git-Tag: 2.0.0alpha4~74 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3fa2e70ebe8f18bcd86812f9d26cf2acd05c9350;p=postgis Fix an issue in the shapefile GUI caused by saving the original shapefile name before processing. This was a bug caused by having two separate passes during export; we were saving the original export shapefile name during the first loop, and so when we came to free() the temporary name at the end of export it would only free the shapefile name from the last iteration, and do it multiple times causing random crashes. git-svn-id: http://svn.osgeo.org/postgis/trunk@9030 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/loader/shp2pgsql-gui.c b/loader/shp2pgsql-gui.c index 5505e2705..aff28ff7a 100644 --- a/loader/shp2pgsql-gui.c +++ b/loader/shp2pgsql-gui.c @@ -1800,27 +1800,7 @@ pgui_action_export(GtkWidget *widget, gpointer data) gtk_widget_hide(dialog_folderchooser); folder_path = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(dialog_folderchooser)); - - /* Loop through each of the files and set the output filename to the path with the table name - appended. We do this as a separate pass here in case we wish to do any validation in future. */ - while (is_valid) - { - /* Grab the SHPDUMPERCONFIG for this row */ - gtk_tree_model_get(GTK_TREE_MODEL(export_table_list_store), &iter, EXPORT_POINTER_COLUMN, &gptr, -1); - dumper_table_config = (SHPDUMPERCONFIG *)gptr; - - orig_shapefile = dumper_table_config->shp_file; - output_shapefile = malloc(strlen(folder_path) + strlen(dumper_table_config->shp_file) + 2); - strcpy(output_shapefile, folder_path); - strcat(output_shapefile, G_DIR_SEPARATOR_S); - strcat(output_shapefile, dumper_table_config->shp_file); - - dumper_table_config->shp_file = output_shapefile; - - /* Get next entry */ - is_valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(export_table_list_store), &iter); - } - + /* Now everything is set up, let's extract the tables */ is_valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(export_table_list_store), &iter); while (is_valid) @@ -1856,6 +1836,15 @@ pgui_action_export(GtkWidget *widget, gpointer data) goto export_cleanup; } + /* Save the original shapefile name, then create a temporary version containing the full path */ + orig_shapefile = dumper_table_config->shp_file; + output_shapefile = malloc(strlen(folder_path) + strlen(dumper_table_config->shp_file) + 2); + strcpy(output_shapefile, folder_path); + strcat(output_shapefile, G_DIR_SEPARATOR_S); + strcat(output_shapefile, dumper_table_config->shp_file); + + dumper_table_config->shp_file = output_shapefile; + /* Display the progress dialog */ gtk_label_set_text(GTK_LABEL(label_progress), _("Initialising...")); gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress), 0.0);