浏览代码

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 年之前
父节点
当前提交
413741ef6a
共有 2 个文件被更改,包括 14 次插入7 次删除
  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"));
 	    G_fatal_error(_("Out of memory"));
 
 
 	if (type > 0) {
 	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++;
 	    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 new feature id (level 2)
    \return offset into file where the feature starts (level 1)
    \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,
 off_t Vect_write_line(struct Map_info *Map, int type,
 		      const struct line_pnts *points, const struct line_cats *cats)
 		      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 = 
     offset = 
 	(*Vect_write_line_array[Map->format][Map->level]) (Map, type, points,
 	(*Vect_write_line_array[Map->format][Map->level]) (Map, type, points,
 							   cats);
 							   cats);
-
+    
+    /*
     if (offset == -1)
     if (offset == -1)
 	G_fatal_error(_("Unable to write feature (negative offset)"));
 	G_fatal_error(_("Unable to write feature (negative offset)"));
-
+    */
     /* NOTE: returns new line id on level 2 and file offset on level 1 */
     /* NOTE: returns new line id on level 2 and file offset on level 1 */
     return offset;
     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,
     ret = (*Vect_rewrite_line_array[Map->format][Map->level]) (Map, line, type,
 							       offset,
 							       offset,
 							       points, cats);
 							       points, cats);
-    
+    /*
     if (ret == -1)
     if (ret == -1)
 	G_fatal_error(_("Unable to rewrite feature %d"), line);
 	G_fatal_error(_("Unable to rewrite feature %d"), line);
-
+    */
     return ret;
     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);
     ret = (*Vect_delete_line_array[Map->format][Map->level]) (Map, line);
 
 
+    /*
     if (ret == -1)
     if (ret == -1)
 	G_fatal_error(_("Unable to delete feature id %d from vector map <%s>"),
 	G_fatal_error(_("Unable to delete feature id %d from vector map <%s>"),
 		      line, Vect_get_full_name(Map));
 		      line, Vect_get_full_name(Map));
-
+    */
     return ret;
     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);
     ret = (*Vect_restore_line_array[Map->format][Map->level]) (Map, line, offset);
 
 
+    /*
     if (ret == -1)
     if (ret == -1)
 	G_fatal_error(_("Unable to restore feature %d from vector map <%s>"),
 	G_fatal_error(_("Unable to restore feature %d from vector map <%s>"),
 		      line, Map->name);
 		      line, Map->name);
-    
+    */
     return ret;
     return ret;
 }
 }