[GRASS-SVN] r54920 - grass/trunk/lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Feb 5 04:32:23 PST 2013


Author: mmetz
Date: 2013-02-05 04:32:22 -0800 (Tue, 05 Feb 2013)
New Revision: 54920

Modified:
   grass/trunk/lib/vector/Vlib/build.c
   grass/trunk/lib/vector/Vlib/close.c
Log:
Vlib: always clean up spatial index

Modified: grass/trunk/lib/vector/Vlib/build.c
===================================================================
--- grass/trunk/lib/vector/Vlib/build.c	2013-02-05 11:02:47 UTC (rev 54919)
+++ grass/trunk/lib/vector/Vlib/build.c	2013-02-05 12:32:22 UTC (rev 54920)
@@ -1256,7 +1256,6 @@
 	    G_warning(_("Error writing out spatial index file"));
 	    return 0;
 	}
-	dig_spidx_free(plus);
 	Map->plus.Spidx_new = FALSE;
     }
 

Modified: grass/trunk/lib/vector/Vlib/close.c
===================================================================
--- grass/trunk/lib/vector/Vlib/close.c	2013-02-05 11:02:47 UTC (rev 54919)
+++ grass/trunk/lib/vector/Vlib/close.c	2013-02-05 12:32:22 UTC (rev 54920)
@@ -161,27 +161,27 @@
 	else if (Map->format == GV_FORMAT_POSTGIS)
             V2_close_pg(Map);
     }
-    else {
-	/* spatial index must also be closed when opened with topo but
-	 * not modified */
-	/* NOTE: also close sidx for GV_FORMAT_OGR if not direct OGR access */
-	if (Map->format != GV_FORMAT_OGR_DIRECT &&
-	    Map->plus.Spidx_built == TRUE &&
-	    Map->plus.built == GV_BUILD_ALL &&
-            create_link)
-	    fclose(Map->plus.spidx_fp.file);
+    /* spatial index must also be closed when opened with topo but
+     * not modified */
+    /* NOTE: also close sidx for GV_FORMAT_OGR if not direct OGR access */
+    if (Map->format != GV_FORMAT_OGR_DIRECT &&
+	Map->plus.Spidx_built == TRUE &&
+	!Map->support_updated &&
+	create_link) {
+
+	fclose(Map->plus.spidx_fp.file);
     }
+    /* always needed to close tmp files
+     * TODO: do better */
+    G_debug(1, "free spatial index");
+    dig_spidx_free(&(Map->plus));
 
     if (Map->level > 1 && Map->plus.release_support) {
 	G_debug(1, "free topology");
 	dig_free_plus(&(Map->plus));
 
-	G_debug(1, "free spatial index");
-	dig_spidx_free(&(Map->plus));
-
 	G_debug(1, "free category index");
 	dig_cidx_free(&(Map->plus));
-
     }
 
     G_debug(1, "close history file");



More information about the grass-commit mailing list