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

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Mar 16 06:58:30 EDT 2012


Author: martinl
Date: 2012-03-16 03:58:29 -0700 (Fri, 16 Mar 2012)
New Revision: 51073

Modified:
   grass/trunk/lib/vector/Vlib/ascii.c
   grass/trunk/lib/vector/Vlib/write.c
Log:
vlib: don't call G_fatal_error() when unable to write/delete/rewrite a features, return -1 to indicate error


Modified: grass/trunk/lib/vector/Vlib/ascii.c
===================================================================
--- grass/trunk/lib/vector/Vlib/ascii.c	2012-03-16 10:55:43 UTC (rev 51072)
+++ grass/trunk/lib/vector/Vlib/ascii.c	2012-03-16 10:58:29 UTC (rev 51073)
@@ -201,7 +201,10 @@
 	    G_fatal_error(_("Out of memory"));
 
 	if (type > 0) {
-	    Vect_write_line(Map, type, Points, Cats);
+	    if (-1 == Vect_write_line(Map, type, Points, Cats)) {
+		G_warning(_("Unable to write new feature"));
+		return -1;
+	    }
 	    n_lines++;
 	}
 	

Modified: grass/trunk/lib/vector/Vlib/write.c
===================================================================
--- grass/trunk/lib/vector/Vlib/write.c	2012-03-16 10:55:43 UTC (rev 51072)
+++ grass/trunk/lib/vector/Vlib/write.c	2012-03-16 10:58:29 UTC (rev 51073)
@@ -171,6 +171,7 @@
 
    \return new feature id (level 2)
    \return offset into file where the feature starts (level 1)
+   \return -1 on error
  */
 off_t Vect_write_line(struct Map_info *Map, int type,
 		      const struct line_pnts *points, const struct line_cats *cats)
@@ -190,10 +191,11 @@
     offset = 
 	(*Vect_write_line_array[Map->format][Map->level]) (Map, type, points,
 							   cats);
-
+    
+    /*
     if (offset == -1)
 	G_fatal_error(_("Unable to write feature (negative offset)"));
-
+    */
     /* NOTE: returns new line id on level 2 and file offset on level 1 */
     return offset;
 }
@@ -235,10 +237,10 @@
     ret = (*Vect_rewrite_line_array[Map->format][Map->level]) (Map, line, type,
 							       offset,
 							       points, cats);
-    
+    /*
     if (ret == -1)
 	G_fatal_error(_("Unable to rewrite feature %d"), line);
-
+    */
     return ret;
 }
 
@@ -279,10 +281,11 @@
 
     ret = (*Vect_delete_line_array[Map->format][Map->level]) (Map, line);
 
+    /*
     if (ret == -1)
 	G_fatal_error(_("Unable to delete feature id %d from vector map <%s>"),
 		      line, Vect_get_full_name(Map));
-
+    */
     return ret;
 }
 
@@ -323,9 +326,10 @@
 
     ret = (*Vect_restore_line_array[Map->format][Map->level]) (Map, line, offset);
 
+    /*
     if (ret == -1)
 	G_fatal_error(_("Unable to restore feature %d from vector map <%s>"),
 		      line, Map->name);
-    
+    */
     return ret;
 }



More information about the grass-commit mailing list