Commit 915ac64a authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

use GError for error reporting in PDB invoker methods.

2007-12-02  Sven Neumann  <sven@gimp.org>

	* tools/pdbgen/app.pl: use GError for error reporting in PDB
	invoker methods.

	* tools/pdbgen/pdb/vectors.pdb: use the GError for the 
procedures
	introduced for bug #497159.

	* tools/pdbgen/pdb/fileops.pdb: use the GError from file-load 
and
	file-save procedures.

	* app/pdb/*_cmds.c: regenerated.

	* app/pdb/Makefile.am

	* app/pdb/gimppdberror.[ch]: new file introducing the
	GIMP_PDB_ERROR domain.

	* app/actions/plug-in-commands.c
	* app/actions/vectors-commands.c
	* app/batch.c
	* app/core/gimpimagefile.c
	* app/core/gimppdbprogress.c
	* app/file/file-open.[ch]
	* app/file/file-save.c
	* app/plug-in/gimpplugin-message.c
	* app/plug-in/gimppluginmanager-restore.c
	* app/plug-in/gimppluginprocedure.c
	* app/plug-in/gimptemporaryprocedure.c
	* app/plug-in/plug-in-icc-profile.c
	* app/widgets/gimpbrushselect.c
	* app/widgets/gimpfontselect.c
	* app/widgets/gimpgradientselect.c
	* app/widgets/gimphelp.c
	* app/widgets/gimppaletteselect.c
	* app/widgets/gimppatternselect.c
	* app/widgets/gimppdbdialog.[ch]: changed accordingly.


svn path=/trunk/; revision=24255
parent b43c095c
2007-12-02 Sven Neumann <sven@gimp.org>
* tools/pdbgen/app.pl: use GError for error reporting in PDB
invoker methods.
* tools/pdbgen/pdb/vectors.pdb: use the GError for the procedures
introduced for bug #497159.
* tools/pdbgen/pdb/fileops.pdb: use the GError from file-load and
file-save procedures.
* app/pdb/*_cmds.c: regenerated.
* app/pdb/Makefile.am
* app/pdb/gimppdberror.[ch]: new file introducing the
GIMP_PDB_ERROR domain.
* app/actions/plug-in-commands.c
* app/actions/vectors-commands.c
* app/batch.c
* app/core/gimpimagefile.c
* app/core/gimppdbprogress.c
* app/file/file-open.[ch]
* app/file/file-save.c
* app/plug-in/gimpplugin-message.c
* app/plug-in/gimppluginmanager-restore.c
* app/plug-in/gimppluginprocedure.c
* app/plug-in/gimptemporaryprocedure.c
* app/plug-in/plug-in-icc-profile.c
* app/widgets/gimpbrushselect.c
* app/widgets/gimpfontselect.c
* app/widgets/gimpgradientselect.c
* app/widgets/gimphelp.c
* app/widgets/gimppaletteselect.c
* app/widgets/gimppatternselect.c
* app/widgets/gimppdbdialog.[ch]: changed accordingly.
2007-12-02 Sven Neumann <sven@gimp.org>
* plug-ins/common/tiff-load.c (load_image): removed pointless and
......
......@@ -294,19 +294,30 @@ plug_in_procedure_execute (GimpPlugInProcedure *procedure,
GValueArray *args,
gint n_args)
{
GError *error = NULL;
gimp_value_array_truncate (args, n_args);
/* run the plug-in procedure */
gimp_procedure_execute_async (GIMP_PROCEDURE (procedure), gimp,
gimp_get_user_context (gimp),
GIMP_PROGRESS (display), args,
GIMP_OBJECT (display));
GIMP_OBJECT (display), &error);
/* remember only image plug-ins */
if (GIMP_PROCEDURE (procedure)->num_args >= 2 &&
GIMP_IS_PARAM_SPEC_IMAGE_ID (GIMP_PROCEDURE (procedure)->args[1]))
if (error)
{
gimp_message (gimp, G_OBJECT (display), GIMP_MESSAGE_ERROR,
"%s", error->message);
g_error_free (error);
}
else
{
gimp_plug_in_manager_history_add (gimp->plug_in_manager, procedure);
/* remember only image plug-ins */
if (GIMP_PROCEDURE (procedure)->num_args >= 2 &&
GIMP_IS_PARAM_SPEC_IMAGE_ID (GIMP_PROCEDURE (procedure)->args[1]))
{
gimp_plug_in_manager_history_add (gimp->plug_in_manager, procedure);
}
}
}
......
......@@ -310,6 +310,7 @@ vectors_selection_to_vectors_cmd_callback (GtkAction *action,
GimpProcedure *procedure;
GValueArray *args;
GimpDisplay *display;
GError *error = NULL;
return_if_no_image (image, data);
return_if_no_widget (widget, data);
......@@ -338,9 +339,16 @@ vectors_selection_to_vectors_cmd_callback (GtkAction *action,
gimp_procedure_execute_async (procedure, image->gimp,
action_data_get_context (data),
GIMP_PROGRESS (display), args,
GIMP_OBJECT (display));
GIMP_OBJECT (display), &error);
g_value_array_free (args);
if (error)
{
gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_ERROR,
"%s", error->message);
g_error_free (error);
}
}
void
......
......@@ -140,7 +140,8 @@ batch_run_cmd (Gimp *gimp,
{
GValueArray *args;
GValueArray *return_vals;
gint i = 0;
GError *error = NULL;
gint i = 0;
args = gimp_procedure_get_arguments (procedure);
......@@ -153,26 +154,45 @@ batch_run_cmd (Gimp *gimp,
return_vals =
gimp_pdb_execute_procedure_by_name_args (gimp->pdb,
gimp_get_user_context (gimp),
NULL,
NULL, &error,
proc_name, args);
switch (g_value_get_enum (&return_vals->values[0]))
{
case GIMP_PDB_EXECUTION_ERROR:
g_printerr ("batch command: experienced an execution error.\n");
if (error)
{
g_printerr ("batch command experienced an execution error: %s\n",
error->message);
}
else
{
g_printerr ("batch command experienced an execution error\n");
}
break;
case GIMP_PDB_CALLING_ERROR:
g_printerr ("batch command: experienced a calling error.\n");
if (error)
{
g_printerr ("batch command experienced a calling error: %s\n",
error->message);
}
else
{
g_printerr ("batch command experienced a calling error\n");
}
break;
case GIMP_PDB_SUCCESS:
g_printerr ("batch command: executed successfully.\n");
g_printerr ("batch command executed successfully\n");
break;
}
g_value_array_free (return_vals);
g_value_array_free (args);
if (error)
g_error_free (error);
return;
}
......@@ -247,7 +247,7 @@ gimp_imagefile_create_thumbnail (GimpImagefile *imagefile,
image = file_open_thumbnail (imagefile->gimp, context, progress,
thumbnail->image_uri, size,
&mime_type, &width, &height);
&mime_type, &width, &height, NULL);
if (image)
{
......
......@@ -275,7 +275,7 @@ gimp_pdb_progress_run_callback (GimpPdbProgress *progress,
return_vals =
gimp_pdb_execute_procedure_by_name (progress->pdb,
progress->context,
NULL,
NULL, NULL,
progress->callback_name,
GIMP_TYPE_INT32, command,
G_TYPE_STRING, text,
......
......@@ -146,7 +146,7 @@ file_open_image (Gimp *gimp,
return_vals =
gimp_pdb_execute_procedure_by_name (gimp->pdb,
context, progress,
context, progress, error,
GIMP_OBJECT (file_proc)->name,
GIMP_TYPE_INT32, run_mode,
G_TYPE_STRING, filename,
......@@ -176,18 +176,21 @@ file_open_image (Gimp *gimp,
}
else
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("%s plug-in returned SUCCESS but did not "
"return an image"),
gimp_plug_in_procedure_get_label (file_proc));
if (error && ! *error)
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("%s plug-in returned SUCCESS but did not "
"return an image"),
gimp_plug_in_procedure_get_label (file_proc));
*status = GIMP_PDB_EXECUTION_ERROR;
}
}
else if (*status != GIMP_PDB_CANCEL)
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("%s plug-In could not open image"),
gimp_plug_in_procedure_get_label (file_proc));
if (error && ! *error)
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("%s plug-In could not open image"),
gimp_plug_in_procedure_get_label (file_proc));
}
g_value_array_free (return_vals);
......@@ -209,7 +212,8 @@ file_open_thumbnail (Gimp *gimp,
gint size,
const gchar **mime_type,
gint *image_width,
gint *image_height)
gint *image_height,
GError **error)
{
GimpPlugInProcedure *file_proc;
GimpProcedure *procedure;
......@@ -220,6 +224,7 @@ file_open_thumbnail (Gimp *gimp,
g_return_val_if_fail (mime_type != NULL, NULL);
g_return_val_if_fail (image_width != NULL, NULL);
g_return_val_if_fail (image_height != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
*image_width = 0;
*image_height = 0;
......@@ -246,7 +251,7 @@ file_open_thumbnail (Gimp *gimp,
return_vals =
gimp_pdb_execute_procedure_by_name (gimp->pdb,
context, progress,
context, progress, error,
GIMP_OBJECT (procedure)->name,
G_TYPE_STRING, filename,
GIMP_TYPE_INT32, size,
......
......@@ -41,7 +41,8 @@ GimpImage * file_open_thumbnail (Gimp *gimp,
gint size,
const gchar **mime_type,
gint *image_width,
gint *image_height);
gint *image_height,
GError **error);
GimpImage * file_open_with_display (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
......
......@@ -135,7 +135,7 @@ file_save (GimpImage *image,
return_vals =
gimp_pdb_execute_procedure_by_name (image->gimp->pdb,
context, progress,
context, progress, error,
GIMP_OBJECT (file_proc)->name,
GIMP_TYPE_INT32, run_mode,
GIMP_TYPE_IMAGE_ID, image_ID,
......@@ -189,9 +189,12 @@ file_save (GimpImage *image,
}
else if (status != GIMP_PDB_CANCEL)
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("%s plug-in could not save image"),
gimp_plug_in_procedure_get_label (file_proc));
if (error && *error == NULL)
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("%s plug-in could not save image"),
gimp_plug_in_procedure_get_label (file_proc));
}
}
g_object_unref (image);
......
......@@ -11,6 +11,8 @@ libapppdb_a_SOURCES = \
gimppdb.h \
gimppdb-query.c \
gimppdb-query.h \
gimppdberror.c \
gimppdberror.h \
gimpprocedure.c \
gimpprocedure.h
......
......@@ -41,11 +41,12 @@
static GValueArray *
brush_new_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brush_new_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
......@@ -73,11 +74,12 @@ brush_new_invoker (GimpProcedure *procedure,
}
static GValueArray *
brush_duplicate_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brush_duplicate_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
......@@ -115,11 +117,12 @@ brush_duplicate_invoker (GimpProcedure *procedure,
}
static GValueArray *
brush_is_generated_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brush_is_generated_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
......@@ -148,11 +151,12 @@ brush_is_generated_invoker (GimpProcedure *procedure,
}
static GValueArray *
brush_rename_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brush_rename_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
......@@ -186,11 +190,12 @@ brush_rename_invoker (GimpProcedure *procedure,
}
static GValueArray *
brush_delete_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brush_delete_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *name;
......@@ -225,11 +230,12 @@ brush_delete_invoker (GimpProcedure *procedure,
}
static GValueArray *
brush_is_editable_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brush_is_editable_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
......@@ -258,11 +264,12 @@ brush_is_editable_invoker (GimpProcedure *procedure,
}
static GValueArray *
brush_get_info_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brush_get_info_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
......@@ -304,11 +311,12 @@ brush_get_info_invoker (GimpProcedure *procedure,
}
static GValueArray *
brush_get_pixels_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brush_get_pixels_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
......@@ -369,11 +377,12 @@ brush_get_pixels_invoker (GimpProcedure *procedure,
}
static GValueArray *
brush_get_spacing_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brush_get_spacing_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
......@@ -402,11 +411,12 @@ brush_get_spacing_invoker (GimpProcedure *procedure,
}
static GValueArray *
brush_set_spacing_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brush_set_spacing_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *name;
......@@ -430,11 +440,12 @@ brush_set_spacing_invoker (GimpProcedure *procedure,
}
static GValueArray *
brush_get_shape_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brush_get_shape_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
......@@ -463,11 +474,12 @@ brush_get_shape_invoker (GimpProcedure *procedure,
}
static GValueArray *
brush_get_radius_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brush_get_radius_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
......@@ -496,11 +508,12 @@ brush_get_radius_invoker (GimpProcedure *procedure,
}
static GValueArray *
brush_get_spikes_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brush_get_spikes_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
......@@ -529,11 +542,12 @@ brush_get_spikes_invoker (GimpProcedure *procedure,
}
static GValueArray *
brush_get_hardness_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brush_get_hardness_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
......@@ -562,11 +576,12 @@ brush_get_hardness_invoker (GimpProcedure *procedure,
}
static GValueArray *
brush_get_aspect_ratio_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brush_get_aspect_ratio_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
......@@ -595,11 +610,12 @@ brush_get_aspect_ratio_invoker (GimpProcedure *procedure,
}
static GValueArray *
brush_get_angle_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brush_get_angle_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
......@@ -628,11 +644,12 @@ brush_get_angle_invoker (GimpProcedure *procedure,
}
static GValueArray *
brush_set_shape_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brush_set_shape_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
......@@ -667,11 +684,12 @@ brush_set_shape_invoker (GimpProcedure *procedure,
}
static GValueArray *
brush_set_radius_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brush_set_radius_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
......@@ -706,11 +724,12 @@ brush_set_radius_invoker (GimpProcedure *procedure,
}
static GValueArray *
brush_set_spikes_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brush_set_spikes_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
......@@ -745,11 +764,12 @@ brush_set_spikes_invoker (GimpProcedure *procedure,
}
static GValueArray *
brush_set_hardness_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brush_set_hardness_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
......@@ -784,11 +804,12 @@ brush_set_hardness_invoker (GimpProcedure *procedure,
}
static GValueArray *
brush_set_aspect_ratio_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brush_set_aspect_ratio_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
......@@ -823,11 +844,12 @@ brush_set_aspect_ratio_invoker (GimpProcedure *procedure,
}
static GValueArray *
brush_set_angle_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brush_set_angle_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
......
......@@ -35,11 +35,12 @@
static GValueArray *
brushes_popup_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brushes_popup_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *brush_callback;
......@@ -74,11 +75,12 @@ brushes_popup_invoker (GimpProcedure *procedure,
}
static GValueArray *
brushes_close_popup_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
brushes_close_popup_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *brush_callback;
......@@ -98,11 +100,12 @@ brushes_close_popup_invoker (GimpProcedure *procedure,
}
static GValueArray *
brushes_set_popup_invoker (GimpProcedure *procedure,
Gimp *gimp,