浏览代码

ogsf: Warn and fail when gsd primitives fail

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@72947 15284696-431f-4ddb-bdfa-cd5b030d7da7
Huidae Cho 6 年之前
父节点
当前提交
6514b8adbd
共有 3 个文件被更改,包括 15 次插入3 次删除
  1. 8 2
      lib/ogsf/gsd_img_ppm.c
  2. 4 1
      lib/ogsf/gsd_img_tif.c
  3. 3 0
      lib/ogsf/gsd_prim.c

+ 8 - 2
lib/ogsf/gsd_img_ppm.c

@@ -46,7 +46,10 @@ int GS_write_ppm(const char *name)
     FILE *fp;
     FILE *fp;
     unsigned char *pixbuf;
     unsigned char *pixbuf;
 
 
-    gsd_getimage(&pixbuf, &xsize, &ysize);
+    if (0 == gsd_getimage(&pixbuf, &xsize, &ysize)) {
+	G_warning(_("Unable to get image of current GL screen"));
+	return (1);
+    }
 
 
     if (NULL == (fp = fopen(name, "w"))) {
     if (NULL == (fp = fopen(name, "w"))) {
 	G_warning(_("Unable to open file <%s> for writing"), name);
 	G_warning(_("Unable to open file <%s> for writing"), name);
@@ -89,7 +92,10 @@ int GS_write_zoom(const char *name, unsigned int xsize, unsigned int ysize)
     FILE *fp;
     FILE *fp;
     unsigned char *pixbuf;
     unsigned char *pixbuf;
 
 
-    gsd_writeView(&pixbuf, xsize, ysize);
+    if (0 == gsd_writeView(&pixbuf, xsize, ysize)) {
+	G_warning(_("Unable to write view"));
+	return (1);
+    }
 
 
     if (NULL == (fp = fopen(name, "w"))) {
     if (NULL == (fp = fopen(name, "w"))) {
 	G_warning(_("Unable to open file <%s> for writing"), name);
 	G_warning(_("Unable to open file <%s> for writing"), name);

+ 4 - 1
lib/ogsf/gsd_img_tif.c

@@ -59,7 +59,10 @@ int GS_write_tif(const char *name)
     unsigned char *buf, *tmpptr;
     unsigned char *buf, *tmpptr;
     unsigned char *pixbuf;
     unsigned char *pixbuf;
 
 
-    gsd_getimage(&pixbuf, &xsize, &ysize);
+    if (0 == gsd_getimage(&pixbuf, &xsize, &ysize)) {
+	G_warning(_("Unable to get image of current GL screen"));
+	return (1);
+    }
 
 
     out = TIFFOpen(name, "w");
     out = TIFFOpen(name, "w");
     if (out == NULL) {
     if (out == NULL) {

+ 3 - 0
lib/ogsf/gsd_prim.c

@@ -947,6 +947,9 @@ int gsd_getViewport(GLint tmp[4], GLint num[2])
 
 
    \param pixbuf data buffer
    \param pixbuf data buffer
    \param xsize,ysize picture dimension
    \param xsize,ysize picture dimension
+
+   \return 0 on failure
+   \return 1 on success
  */
  */
 int gsd_writeView(unsigned char **pixbuf, unsigned int xsize,
 int gsd_writeView(unsigned char **pixbuf, unsigned int xsize,
 		  unsigned int ysize)
 		  unsigned int ysize)