]> granicus.if.org Git - postgis/commitdiff
Fix an issue in the shapefile GUI caused by saving the original shapefile name before...
authorMark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>
Sat, 4 Feb 2012 02:36:44 +0000 (02:36 +0000)
committerMark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>
Sat, 4 Feb 2012 02:36:44 +0000 (02:36 +0000)
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

loader/shp2pgsql-gui.c

index 5505e2705e5ba07fdfa0ac3c767eba67cc6d6d77..aff28ff7afd9f656ac587873cd9f8ae53cac619c 100644 (file)
@@ -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);