gimp r26920 - in trunk: . plug-ins/script-fu
- From: mitch svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26920 - in trunk: . plug-ins/script-fu
- Date: Wed, 10 Sep 2008 20:33:50 +0000 (UTC)
Author: mitch
Date: Wed Sep 10 20:33:50 2008
New Revision: 26920
URL: http://svn.gnome.org/viewvc/gimp?rev=26920&view=rev
Log:
2008-09-10 Michael Natterer <mitch gimp org>
Change Script-Fu error handling to properly use the new error
message passing in PDB return values:
* plug-ins/script-fu/script-fu-scripts.[ch]: remove function
script_fu_error_msg().
* plug-ins/script-fu/script-fu-interface.c (script_fu_ok): output
errors of interactive script-fu dialogs directly here with
g_message().
* plug-ins/script-fu/script-fu-scripts.c (script_fu_run_command):
add GError and return the error message instead of displaying it.
(script_fu_load_script): show the returned error here (and make it
more specific than the former script_fu_error_msg() did).
(script_fu_script_proc): return error messages via the procedure's
return values.
* plug-ins/script-fu/scheme-wrapper.c
(script_fu_marshal_procedure_call): if an error message was
returned from the PDB call, pass it to foreign_error() so it ends
up where it should (consle, text console or error string).
* plug-ins/script-fu/script-fu-console.c
* plug-ins/script-fu/script-fu-text-console.c: set the error
handler to PLUGIN while interpreting scheme, we handle errors
from calling back into the PDB ourselves now.
Modified:
trunk/ChangeLog
trunk/plug-ins/script-fu/scheme-wrapper.c
trunk/plug-ins/script-fu/script-fu-console.c
trunk/plug-ins/script-fu/script-fu-interface.c
trunk/plug-ins/script-fu/script-fu-scripts.c
trunk/plug-ins/script-fu/script-fu-scripts.h
trunk/plug-ins/script-fu/script-fu-text-console.c
Modified: trunk/plug-ins/script-fu/scheme-wrapper.c
==============================================================================
--- trunk/plug-ins/script-fu/scheme-wrapper.c (original)
+++ trunk/plug-ins/script-fu/scheme-wrapper.c Wed Sep 10 20:33:50 2008
@@ -1309,16 +1309,34 @@
switch (values[0].data.d_status)
{
case GIMP_PDB_EXECUTION_ERROR:
- g_snprintf (error_str, sizeof (error_str),
- "Procedure execution of %s failed",
- proc_name);
+ if (nvalues > 1 && values[1].type == GIMP_PDB_STRING)
+ {
+ g_snprintf (error_str, sizeof (error_str),
+ "Procedure execution of %s failed: %s",
+ proc_name, values[1].data.d_string);
+ }
+ else
+ {
+ g_snprintf (error_str, sizeof (error_str),
+ "Procedure execution of %s failed",
+ proc_name);
+ }
return foreign_error (sc, error_str, 0);
break;
case GIMP_PDB_CALLING_ERROR:
- g_snprintf (error_str, sizeof (error_str),
- "Procedure execution of %s failed on invalid input arguments",
- proc_name);
+ if (nvalues > 1 && values[1].type == GIMP_PDB_STRING)
+ {
+ g_snprintf (error_str, sizeof (error_str),
+ "Procedure execution of %s failed on invalid input arguments: %s",
+ proc_name, values[1].data.d_string);
+ }
+ else
+ {
+ g_snprintf (error_str, sizeof (error_str),
+ "Procedure execution of %s failed on invalid input arguments",
+ proc_name);
+ }
return foreign_error (sc, error_str, 0);
break;
Modified: trunk/plug-ins/script-fu/script-fu-console.c
==============================================================================
--- trunk/plug-ins/script-fu/script-fu-console.c (original)
+++ trunk/plug-ins/script-fu/script-fu-console.c Wed Sep 10 20:33:50 2008
@@ -597,6 +597,9 @@
output = g_string_new ("");
ts_register_output_func (ts_gstring_output_func, output);
+
+ gimp_plugin_set_pdb_error_handler (GIMP_PDB_ERROR_HANDLER_PLUGIN);
+
if (ts_interpret_string (list->data) != 0)
{
script_fu_output_to_console (TS_OUTPUT_ERROR,
@@ -612,6 +615,8 @@
console);
}
+ gimp_plugin_set_pdb_error_handler (GIMP_PDB_ERROR_HANDLER_INTERNAL);
+
g_string_free (output, TRUE);
gimp_displays_flush ();
Modified: trunk/plug-ins/script-fu/script-fu-interface.c
==============================================================================
--- trunk/plug-ins/script-fu/script-fu-interface.c (original)
+++ trunk/plug-ins/script-fu/script-fu-interface.c Wed Sep 10 20:33:50 2008
@@ -911,7 +911,7 @@
ts_register_output_func (ts_gstring_output_func, output);
if (ts_interpret_string (command))
- script_fu_error_msg (command, output->str);
+ g_message (_("Error while executing\n%s\n\n%s"), command, output->str);
g_string_free (output, TRUE);
Modified: trunk/plug-ins/script-fu/script-fu-scripts.c
==============================================================================
--- trunk/plug-ins/script-fu/script-fu-scripts.c (original)
+++ trunk/plug-ins/script-fu/script-fu-scripts.c Wed Sep 10 20:33:50 2008
@@ -53,28 +53,29 @@
* Local Functions
*/
-static gboolean script_fu_run_command (const gchar *command);
-static void script_fu_load_script (const GimpDatafileData *file_data,
- gpointer user_data);
-static gboolean script_fu_install_script (gpointer foo,
- GList *scripts,
- gpointer bar);
-static void script_fu_install_menu (SFMenu *menu);
-static gboolean script_fu_remove_script (gpointer foo,
- GList *scripts,
- gpointer bar);
-static void script_fu_script_proc (const gchar *name,
- gint nparams,
- const GimpParam *params,
- gint *nreturn_vals,
- GimpParam **return_vals);
-
-static SFScript *script_fu_find_script (const gchar *name);
-static void script_fu_free_script (SFScript *script);
-
-static void script_fu_menu_map (SFScript *script);
-static gint script_fu_menu_compare (gconstpointer a,
- gconstpointer b);
+static gboolean script_fu_run_command (const gchar *command,
+ GError **error);
+static void script_fu_load_script (const GimpDatafileData *file_data,
+ gpointer user_data);
+static gboolean script_fu_install_script (gpointer foo,
+ GList *scripts,
+ gpointer bar);
+static void script_fu_install_menu (SFMenu *menu);
+static gboolean script_fu_remove_script (gpointer foo,
+ GList *scripts,
+ gpointer bar);
+static void script_fu_script_proc (const gchar *name,
+ gint nparams,
+ const GimpParam *params,
+ gint *nreturn_vals,
+ GimpParam **return_vals);
+
+static SFScript *script_fu_find_script (const gchar *name);
+static void script_fu_free_script (SFScript *script);
+
+static void script_fu_menu_map (SFScript *script);
+static gint script_fu_menu_compare (gconstpointer a,
+ gconstpointer b);
/*
@@ -661,18 +662,12 @@
return sc->NIL;
}
-void
-script_fu_error_msg (const gchar *command,
- const gchar *msg)
-{
- g_message (_("Error while executing\n%s\n\n%s"), command, msg);
-}
-
/* private functions */
static gboolean
-script_fu_run_command (const gchar *command)
+script_fu_run_command (const gchar *command,
+ GError **error)
{
GString *output = g_string_new ("");
gboolean success = FALSE;
@@ -682,7 +677,7 @@
if (ts_interpret_string (command))
{
- script_fu_error_msg (command, output->str);
+ g_set_error_literal (error, 0, 0, output->str);
}
else
{
@@ -700,13 +695,19 @@
{
if (gimp_datafiles_check_extension (file_data->filename, ".scm"))
{
- gchar *escaped = script_fu_strescape (file_data->filename);
- gchar *command;
+ gchar *escaped = script_fu_strescape (file_data->filename);
+ gchar *command;
+ GError *error = NULL;
command = g_strdup_printf ("(load \"%s\")", escaped);
g_free (escaped);
- script_fu_run_command (command);
+ if (! script_fu_run_command (command, &error))
+ {
+ g_message (_("Error while loading\n\"%s\"\n\n%s"),
+ file_data->filename, error->message);
+ g_clear_error (&error);
+ }
#ifdef G_OS_WIN32
/* No, I don't know why, but this is
@@ -903,9 +904,10 @@
gint *nreturn_vals,
GimpParam **return_vals)
{
- static GimpParam values[1];
+ static GimpParam values[2];
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
SFScript *script;
+ GError *error = NULL;
*nreturn_vals = 1;
*return_vals = values;
@@ -1038,7 +1040,12 @@
command = g_string_free (s, FALSE);
/* run the command through the interpreter */
- script_fu_run_command (command);
+ if (! script_fu_run_command (command, &error))
+ {
+ status = GIMP_PDB_EXECUTION_ERROR;
+ *nreturn_vals = 2;
+ values[2].data.d_string = error->message;
+ }
g_free (command);
}
@@ -1168,7 +1175,12 @@
command = g_string_free (s, FALSE);
/* run the command through the interpreter */
- script_fu_run_command (command);
+ if (! script_fu_run_command (command, &error))
+ {
+ status = GIMP_PDB_EXECUTION_ERROR;
+ *nreturn_vals = 2;
+ values[2].data.d_string = error->message;
+ }
g_free (command);
}
Modified: trunk/plug-ins/script-fu/script-fu-scripts.h
==============================================================================
--- trunk/plug-ins/script-fu/script-fu-scripts.h (original)
+++ trunk/plug-ins/script-fu/script-fu-scripts.h Wed Sep 10 20:33:50 2008
@@ -20,12 +20,12 @@
#define __SCRIPT_FU_SCRIPTS_H__
-void script_fu_find_scripts (const gchar *path);
-pointer script_fu_add_script (scheme *sc, pointer a);
-pointer script_fu_add_menu (scheme *sc, pointer a);
-void script_fu_error_msg (const gchar *command,
- const gchar *msg);
-gchar * script_fu_strescape (const gchar *source);
+void script_fu_find_scripts (const gchar *path);
+pointer script_fu_add_script (scheme *sc,
+ pointer a);
+pointer script_fu_add_menu (scheme *sc,
+ pointer a);
+gchar * script_fu_strescape (const gchar *source);
#endif /* __SCRIPT_FU_SCRIPTS__ */
Modified: trunk/plug-ins/script-fu/script-fu-text-console.c
==============================================================================
--- trunk/plug-ins/script-fu/script-fu-text-console.c (original)
+++ trunk/plug-ins/script-fu/script-fu-text-console.c Wed Sep 10 20:33:50 2008
@@ -46,8 +46,12 @@
ts_print_welcome ();
+ gimp_plugin_set_pdb_error_handler (GIMP_PDB_ERROR_HANDLER_PLUGIN);
+
/* Run the interface */
- ts_interpret_stdin();
+ ts_interpret_stdin ();
+
+ gimp_plugin_set_pdb_error_handler (GIMP_PDB_ERROR_HANDLER_INTERNAL);
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = GIMP_PDB_SUCCESS;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]