gimp r26637 - in trunk: . plug-ins/common



Author: neo
Date: Sun Aug 17 21:39:44 2008
New Revision: 26637
URL: http://svn.gnome.org/viewvc/gimp?rev=26637&view=rev

Log:
2008-08-17  Sven Neumann  <sven gimp org>

	* plug-ins/common/file-pdf.c: in case of an error, pass the 
error
	message with the return values.



Modified:
   trunk/ChangeLog
   trunk/plug-ins/common/file-gif-save.c
   trunk/plug-ins/common/file-pdf.c

Modified: trunk/plug-ins/common/file-gif-save.c
==============================================================================
--- trunk/plug-ins/common/file-gif-save.c	(original)
+++ trunk/plug-ins/common/file-gif-save.c	Sun Aug 17 21:39:44 2008
@@ -289,14 +289,11 @@
       if (export == GIMP_EXPORT_EXPORT)
         gimp_image_delete (image_ID);
 
-      if (status == GIMP_PDB_EXECUTION_ERROR)
+      if (status == GIMP_PDB_EXECUTION_ERROR && error)
         {
-          if (error)
-            {
-              *nreturn_vals = 2;
-              values[1].type          = GIMP_PDB_STRING;
-              values[1].data.d_string = error->message;
-            }
+          *nreturn_vals = 2;
+          values[1].type          = GIMP_PDB_STRING;
+          values[1].data.d_string = error->message;
         }
     }
 

Modified: trunk/plug-ins/common/file-pdf.c
==============================================================================
--- trunk/plug-ins/common/file-pdf.c	(original)
+++ trunk/plug-ins/common/file-pdf.c	Sun Aug 17 21:39:44 2008
@@ -77,7 +77,8 @@
 static gboolean          load_dialog       (PopplerDocument        *doc,
                                             PdfSelectedPages       *pages);
 
-static PopplerDocument * open_document     (const gchar            *filename);
+static PopplerDocument * open_document     (const gchar            *filename,
+                                            GError                **error);
 
 static GdkPixbuf *       get_thumbnail     (PopplerDocument        *doc,
                                             gint                    page,
@@ -327,6 +328,7 @@
   GimpPDBStatusType status   = GIMP_PDB_SUCCESS;
   gint32            image_ID = -1;
   PopplerDocument  *doc      = NULL;
+  GError           *error    = NULL;
 
   run_mode = param[0].data.d_int32;
 
@@ -351,7 +353,7 @@
           /* Possibly retrieve last settings */
           gimp_get_data (LOAD_PROC, &loadvals);
 
-          doc = open_document (param[1].data.d_string);
+          doc = open_document (param[1].data.d_string, &error);
 
           if (!doc)
             {
@@ -371,7 +373,7 @@
           break;
 
         case GIMP_RUN_NONINTERACTIVE:
-          doc = open_document (param[1].data.d_string);
+          doc = open_document (param[1].data.d_string, &error);
 
           if (doc)
             {
@@ -392,8 +394,9 @@
                 }
             }
           else
-            status = GIMP_PDB_EXECUTION_ERROR;
-
+            {
+              status = GIMP_PDB_EXECUTION_ERROR;
+            }
           break;
         }
 
@@ -439,7 +442,7 @@
           /* Possibly retrieve last settings */
           gimp_get_data (LOAD_PROC, &loadvals);
 
-          doc = open_document (param[0].data.d_string);
+          doc = open_document (param[0].data.d_string, &error);
 
           if (doc)
             {
@@ -499,37 +502,46 @@
       status = GIMP_PDB_CALLING_ERROR;
     }
 
+  if (status == GIMP_PDB_EXECUTION_ERROR && error)
+    {
+      *nreturn_vals = 2;
+      values[1].type          = GIMP_PDB_STRING;
+      values[1].data.d_string = error->message;
+    }
+
   values[0].data.d_status = status;
 }
 
 static PopplerDocument*
-open_document (const gchar *filename)
+open_document (const gchar  *filename,
+               GError      **load_error)
 {
   PopplerDocument *doc;
-  GError          *err = NULL;
   gchar           *uri;
+  GError          *error = NULL;
 
-  uri = g_filename_to_uri (filename, NULL, &err);
+  uri = g_filename_to_uri (filename, NULL, &error);
 
-  if (err)
+  if (! uri)
     {
-      g_warning ("Could not convert '%s' to an URI: %s",
-                 gimp_filename_to_utf8 (filename),
-                 err->message);
-
+      g_set_error (load_error, 0, 0,
+                   "Could not convert '%s' to an URI: %s",
+                   gimp_filename_to_utf8 (filename), error->message);
+      g_error_free (error);
       return NULL;
     }
 
-  doc = poppler_document_new_from_file (uri, NULL, &err);
+  doc = poppler_document_new_from_file (uri, NULL, &error);
 
   g_free (uri);
 
-  if (err)
+  if (! doc)
     {
-      g_message (_("Could not open '%s' for reading: %s"),
-                 gimp_filename_to_utf8 (filename),
-                 err->message);
-
+      g_set_error (load_error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                   _("Could not open '%s' for reading: %s"),
+                   gimp_filename_to_utf8 (filename),
+                   error->message);
+      g_error_free (error);
       return NULL;
     }
 



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