Explorar o código

vlib: cosmetics when closing spatial index file

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@58354 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa %!s(int64=11) %!d(string=hai) anos
pai
achega
44641f40af
Modificáronse 1 ficheiros con 9 adicións e 7 borrados
  1. 9 7
      lib/vector/Vlib/close.c

+ 9 - 7
lib/vector/Vlib/close.c

@@ -198,17 +198,19 @@ int Vect_close(struct Map_info *Map)
 	else if (Map->format == GV_FORMAT_POSTGIS)
             V2_close_pg(Map);
     }
-    /* 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 &&
+
+    /* spatial index must also be closed when opened with topo but not
+     * modified */
+    if (Map->plus.spidx_fp.file &&
+        Map->plus.Spidx_built == TRUE &&
 	!Map->support_updated &&
-	Map->plus.built == GV_BUILD_ALL &&
-	create_link) {
+	Map->plus.built == GV_BUILD_ALL) {
 
+        G_debug(1, "spatial index file closed");
 	fclose(Map->plus.spidx_fp.file);
     }
+
+    /* release memory if required */
     if (Map->level > 1 && Map->plus.release_support) {
 	G_debug(1, "free topology, spatial index, and category index");
 	dig_free_plus(&(Map->plus));