Browse Source

vlib: don't call G_fatal_error() when unable to write/delete/rewrite a features, return -1 to indicate error

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@51073 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 13 years ago
parent
commit
413741ef6a
2 changed files with 14 additions and 7 deletions
  1. 4 1
      lib/vector/Vlib/ascii.c
  2. 10 6
      lib/vector/Vlib/write.c

+ 4 - 1
lib/vector/Vlib/ascii.c

@@ -201,7 +201,10 @@ int Vect_read_ascii(FILE *ascii, struct Map_info *Map)
 	    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++;
 	}
 	

+ 10 - 6
lib/vector/Vlib/write.c

@@ -171,6 +171,7 @@ static int (*Vect_restore_line_array[][3]) () = {
 
    \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 @@ off_t Vect_write_line(struct Map_info *Map, int type,
     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 @@ off_t Vect_rewrite_line(struct Map_info *Map, int line, int type,
     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 @@ int Vect_delete_line(struct Map_info *Map, int line)
 
     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 @@ int Vect_restore_line(struct Map_info *Map, int line, off_t offset)
 
     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;
 }