[gimp] plug-ins: properly set returned error in pdb call.



commit 7fce78b2ce8180b9f4e4c02f10a961e762055451
Author: Jehan <jehan girinstud io>
Date:   Sun Dec 10 05:20:23 2017 +0100

    plug-ins: properly set returned error in pdb call.
    
    g_set_error() so that when samplespacing is not a valid argument for
    file-hgt-load, the error is properly propagated.
    Also add a g_warning() to get the error in the terminal as well.

 plug-ins/common/file-raw-data.c |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/plug-ins/common/file-raw-data.c b/plug-ins/common/file-raw-data.c
index b1bc460..d4f875a 100644
--- a/plug-ins/common/file-raw-data.c
+++ b/plug-ins/common/file-raw-data.c
@@ -58,6 +58,19 @@
 
 #define RAW_DEFAULTS_PARASITE  "raw-save-defaults"
 
+#define GIMP_PLUGIN_HGT_LOAD_ERROR gimp_plugin_hgt_load_error_quark ()
+
+typedef enum
+{
+  GIMP_PLUGIN_HGT_LOAD_ARGUMENT_ERROR
+} GimpPluginHGTError;
+
+static GQuark
+gimp_plugin_hgt_load_error_quark (void)
+{
+  return g_quark_from_static_string ("gimp-plugin-hgt-load-error-quark");
+}
+
 typedef enum
 {
   RAW_RGB,          /* RGB Image */
@@ -433,8 +446,10 @@ run (const gchar      *name,
               sample_spacing != 3)
             {
               status = GIMP_PDB_CALLING_ERROR;
-              g_warning ("%d is not a valid sample spacing. Valid values are: 1, 3.",
-                         sample_spacing);
+              g_set_error (&error,
+                           GIMP_PLUGIN_HGT_LOAD_ERROR, GIMP_PLUGIN_HGT_LOAD_ARGUMENT_ERROR,
+                           _("%d is not a valid sample spacing. Valid values are: 1, 3."),
+                           sample_spacing);
             }
           else
             {
@@ -480,6 +495,12 @@ run (const gchar      *name,
               status = GIMP_PDB_EXECUTION_ERROR;
             }
         }
+      if (status != GIMP_PDB_SUCCESS && error)
+        {
+          g_warning ("Loading \"%s\" failed with error: %s",
+                     param[1].data.d_string,
+                     error->message);
+        }
 
       g_free (runtime);
     }


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