[gimp] app: gimp_procedure_execute(): don't use a NULL plug-ins error message



commit 60014630fa732365e03683bb31ac6a2b2511fe79
Author: Michael Natterer <mitch gimp org>
Date:   Fri Mar 14 17:28:42 2014 +0100

    app: gimp_procedure_execute(): don't use a NULL plug-ins error message
    
    return_vals[1] being present and being a string doesn't neccessarily
    mean it comes from the plug-in, it might just as well be its first
    return value, which gets generated and NULL-initialized by the plug-in
    execution code even if the plug-in didn't actually return anything.

 app/pdb/gimpprocedure.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/app/pdb/gimpprocedure.c b/app/pdb/gimpprocedure.c
index 1b367e1..7264809 100644
--- a/app/pdb/gimpprocedure.c
+++ b/app/pdb/gimpprocedure.c
@@ -349,17 +349,17 @@ gimp_procedure_execute (GimpProcedure   *procedure,
            *  from the error message that is optionally passed with
            *  the return values.
            */
-          if (error && *error == NULL)
+          if (error && *error == NULL &&
+              gimp_value_array_length (return_vals) > 1 &&
+              G_VALUE_HOLDS_STRING (gimp_value_array_index (return_vals, 1)))
             {
-              if (gimp_value_array_length (return_vals) > 1 &&
-                  G_VALUE_HOLDS_STRING (gimp_value_array_index (return_vals, 1)))
-                {
-                  GValue *value = gimp_value_array_index (return_vals, 1);
+              GValue      *value   = gimp_value_array_index (return_vals, 1);
+              const gchar *message = g_value_get_string (value);
 
-                  g_set_error_literal (error, GIMP_PDB_ERROR,
-                                       GIMP_PDB_ERROR_FAILED,
-                                      g_value_get_string (value));
-                }
+              if (message)
+                g_set_error_literal (error, GIMP_PDB_ERROR,
+                                     GIMP_PDB_ERROR_FAILED,
+                                     message);
             }
           break;
 


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