From 5e95e896b194ddc892752079dc3a9bc59ec5e914 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Thu, 21 Aug 2008 16:27:06 +0000 Subject: [PATCH] app/plug-in/gimppluginprocedure.c don't just free the return values when 2008-08-21 Sven Neumann * app/plug-in/gimppluginprocedure.c * app/plug-in/gimptemporaryprocedure.c: don't just free the return values when running procedures asynchronously. Instead examine them and display the error message if there's one. * app/plug-in/gimppluginmanager-call.c (gimp_plug_in_manager_call_run_temp): return NULL if procedure->plug_in is not set. * app/plug-in/gimpplugin-message.c: comment. svn path=/trunk/; revision=26700 --- ChangeLog | 13 ++++++++++ app/plug-in/gimpplugin-message.c | 2 +- app/plug-in/gimppluginmanager-call.c | 14 +++-------- app/plug-in/gimppluginprocedure.c | 37 +++++++++++++++++++++++++--- app/plug-in/gimptemporaryprocedure.c | 35 +++++++++++++++++++++++++- 5 files changed, 85 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7e66b663ae..c6423a3b98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2008-08-21 Sven Neumann + + * app/plug-in/gimppluginprocedure.c + * app/plug-in/gimptemporaryprocedure.c: don't just free the return + values when running procedures asynchronously. Instead examine + them and display the error message if there's one. + + * app/plug-in/gimppluginmanager-call.c + (gimp_plug_in_manager_call_run_temp): return NULL if + procedure->plug_in is not set. + + * app/plug-in/gimpplugin-message.c: comment. + 2008-08-21 Michael Natterer * configure.in: removed indentation from blocks after diff --git a/app/plug-in/gimpplugin-message.c b/app/plug-in/gimpplugin-message.c index 60ac353d31..02a4dfb06b 100644 --- a/app/plug-in/gimpplugin-message.c +++ b/app/plug-in/gimpplugin-message.c @@ -436,7 +436,7 @@ gimp_plug_in_handle_proc_error (GimpPlugIn *plug_in, break; case GIMP_PDB_ERROR_HANDLER_PLUGIN: - /* the plug-in is responsible for this error */ + /* the plug-in is responsible for handling this error */ break; } } diff --git a/app/plug-in/gimppluginmanager-call.c b/app/plug-in/gimppluginmanager-call.c index 6932b0c89a..bec1ddfcab 100644 --- a/app/plug-in/gimppluginmanager-call.c +++ b/app/plug-in/gimppluginmanager-call.c @@ -289,7 +289,8 @@ gimp_plug_in_manager_call_run_temp (GimpPlugInManager *manager, GimpTemporaryProcedure *procedure, GValueArray *args) { - GimpPlugIn *plug_in; + GValueArray *return_vals = NULL; + GimpPlugIn *plug_in; g_return_val_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager), NULL); g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); @@ -302,7 +303,6 @@ gimp_plug_in_manager_call_run_temp (GimpPlugInManager *manager, if (plug_in) { GimpPlugInProcFrame *proc_frame; - GValueArray *return_vals; GPProcRun proc_run; proc_frame = gimp_plug_in_proc_frame_push (plug_in, context, progress, @@ -346,13 +346,7 @@ gimp_plug_in_manager_call_run_temp (GimpPlugInManager *manager, gimp_plug_in_proc_frame_unref (proc_frame, plug_in); g_object_unref (plug_in); + } - return return_vals; - } - else - { - /* can we actually ever get here? */ - return gimp_procedure_get_return_values (GIMP_PROCEDURE (procedure), - FALSE, NULL); - } + return return_vals; } diff --git a/app/plug-in/gimppluginprocedure.c b/app/plug-in/gimppluginprocedure.c index 39a44e4d76..2a2666b4da 100644 --- a/app/plug-in/gimppluginprocedure.c +++ b/app/plug-in/gimppluginprocedure.c @@ -231,11 +231,40 @@ gimp_plug_in_procedure_execute_async (GimpProcedure *procedure, plug_in_procedure, args, FALSE, display); - /* In case of errors, gimp_plug_in_manager_call_run() may return - * return_vals, even if run asynchronously. - */ if (return_vals) - g_value_array_free (return_vals); + { + switch (g_value_get_enum (&return_vals->values[0])) + { + case GIMP_PDB_SUCCESS: + break; + + case GIMP_PDB_CALLING_ERROR: + if (return_vals->n_values > 1 && + G_VALUE_HOLDS_STRING (&return_vals->values[1])) + { + gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR, + _("Calling error for procedure '%s':\n" + "%s"), + gimp_object_get_name (GIMP_OBJECT (procedure)), + g_value_get_string (&return_vals->values[1])); + } + break; + + case GIMP_PDB_EXECUTION_ERROR: + if (return_vals->n_values > 1 && + G_VALUE_HOLDS_STRING (&return_vals->values[1])) + { + gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR, + _("Execution error for procedure '%s':\n" + "%s"), + gimp_object_get_name (GIMP_OBJECT (procedure)), + g_value_get_string (&return_vals->values[1])); + } + break; + } + + g_value_array_free (return_vals); + } } const gchar * diff --git a/app/plug-in/gimptemporaryprocedure.c b/app/plug-in/gimptemporaryprocedure.c index 5660995afb..471d555bf6 100644 --- a/app/plug-in/gimptemporaryprocedure.c +++ b/app/plug-in/gimptemporaryprocedure.c @@ -116,7 +116,40 @@ gimp_temporary_procedure_execute_async (GimpProcedure *procedure, GIMP_TEMPORARY_PROCEDURE (procedure), args); - g_value_array_free (return_vals); + if (return_vals) + { + switch (g_value_get_enum (&return_vals->values[0])) + { + case GIMP_PDB_SUCCESS: + break; + + case GIMP_PDB_CALLING_ERROR: + if (return_vals->n_values > 1 && + G_VALUE_HOLDS_STRING (&return_vals->values[1])) + { + gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR, + _("Calling error for procedure '%s':\n" + "%s"), + gimp_object_get_name (GIMP_OBJECT (procedure)), + g_value_get_string (&return_vals->values[1])); + } + break; + + case GIMP_PDB_EXECUTION_ERROR: + if (return_vals->n_values > 1 && + G_VALUE_HOLDS_STRING (&return_vals->values[1])) + { + gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR, + _("Execution error for procedure '%s':\n" + "%s"), + gimp_object_get_name (GIMP_OBJECT (procedure)), + g_value_get_string (&return_vals->values[1])); + } + break; + } + + g_value_array_free (return_vals); + } } const gchar *