[gimp/soc-2010-cage-2] Move file opening block to after some tests



commit d5184754949e304d6a907e1404cea52a275cc71e
Author: Nelson A. de Oliveira <naoliv debian org>
Date:   Tue Nov 9 16:06:00 2010 -0200

    Move file opening block to after some tests
    
    Instead fclosing fp for every return, it's better to move the block
    to a lower position, since it's not used before.

 plug-ins/common/file-pcx.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/plug-ins/common/file-pcx.c b/plug-ins/common/file-pcx.c
index 57cd29a..bff09a6 100644
--- a/plug-ins/common/file-pcx.c
+++ b/plug-ins/common/file-pcx.c
@@ -674,14 +674,6 @@ save_image (const gchar  *filename,
       return FALSE;
   }
 
-  if ((fp = g_fopen (filename, "wb")) == NULL)
-    {
-      g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
-                   _("Could not open '%s' for writing: %s"),
-                   gimp_filename_to_utf8 (filename), g_strerror (errno));
-      return FALSE;
-    }
-
   pixels = (guchar *) g_malloc (width * height * pcx_header.planes);
   gimp_pixel_rgn_get_rect (&pixel_rgn, pixels, 0, 0, width, height);
 
@@ -711,6 +703,14 @@ save_image (const gchar  *filename,
       return FALSE;
     }
 
+  if ((fp = g_fopen (filename, "wb")) == NULL)
+    {
+      g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
+                   _("Could not open '%s' for writing: %s"),
+                   gimp_filename_to_utf8 (filename), g_strerror (errno));
+      return FALSE;
+    }
+
   pcx_header.x1 = GUINT16_TO_LE ((guint16)offset_x);
   pcx_header.y1 = GUINT16_TO_LE ((guint16)offset_y);
   pcx_header.x2 = GUINT16_TO_LE ((guint16)(offset_x + width - 1));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]