gimp r26620 - in trunk: . app/pdb plug-ins/common
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26620 - in trunk: . app/pdb plug-ins/common
- Date: Sun, 17 Aug 2008 12:13:46 +0000 (UTC)
Author: neo
Date: Sun Aug 17 12:13:46 2008
New Revision: 26620
URL: http://svn.gnome.org/viewvc/gimp?rev=26620&view=rev
Log:
2008-08-17 Sven Neumann <sven gimp org>
Next step towards fixing bug #344818:
* app/pdb/gimpprocedure.c (gimp_procedure_execute): if the error
has not already been set, construct one from the error message
that is optionally passed with the return values.
* plug-ins/common/file-png.c: changed to pass an error message
with the return values instead of calling g_message() in case of
an error.
Modified:
trunk/ChangeLog
trunk/app/pdb/gimpprocedure.c
trunk/plug-ins/common/file-png.c
Modified: trunk/app/pdb/gimpprocedure.c
==============================================================================
--- trunk/app/pdb/gimpprocedure.c (original)
+++ trunk/app/pdb/gimpprocedure.c Sun Aug 17 12:13:46 2008
@@ -332,15 +332,41 @@
args,
error);
- if (! return_vals)
+
+ if (return_vals)
{
+ if (g_value_get_enum (&return_vals->values[0]) != GIMP_PDB_SUCCESS)
+ {
+ /* If the error has not already been set, construct one
+ * from the error message that is optionally passed with
+ * the return values.
+ */
+ if (error && *error == NULL)
+ {
+ if (return_vals->n_values > 1 &&
+ G_VALUE_HOLDS_STRING (&return_vals->values[1]))
+ {
+ g_set_error (error, 0, 0,
+ g_value_get_string (&return_vals->values[1]));
+ }
+ }
+ }
+ }
+ else
+ {
+ g_warning ("%s: no return values, shouldn't happen", G_STRFUNC);
+
pdb_error = g_error_new (GIMP_PDB_ERROR, GIMP_PDB_INVALID_RETURN_VALUE,
_("Procedure '%s' returned no return values"),
gimp_object_get_name (GIMP_OBJECT (procedure)));
return_vals = gimp_procedure_get_return_values (procedure, FALSE,
pdb_error);
- g_propagate_error (error, pdb_error);
+ if (error && *error == NULL)
+ g_propagate_error (error, pdb_error);
+ else
+ g_error_free (pdb_error);
+
}
return return_vals;
Modified: trunk/plug-ins/common/file-png.c
==============================================================================
--- trunk/plug-ins/common/file-png.c (original)
+++ trunk/plug-ins/common/file-png.c Sun Aug 17 12:13:46 2008
@@ -119,11 +119,13 @@
GimpParam **return_vals);
static gint32 load_image (const gchar *filename,
- gboolean interactive);
+ gboolean interactive,
+ GError **error);
static gboolean save_image (const gchar *filename,
gint32 image_ID,
gint32 drawable_ID,
- gint32 orig_image_ID);
+ gint32 orig_image_ID,
+ GError **error);
static void respin_cmap (png_structp pp,
png_infop info,
@@ -386,13 +388,14 @@
gint32 drawable_ID;
gint32 orig_image_ID;
GimpExportReturn export = GIMP_EXPORT_CANCEL;
+ GError *error = NULL;
INIT_I18N ();
*nreturn_vals = 1;
*return_vals = values;
- values[0].type = GIMP_PDB_STATUS;
+ values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
if (strcmp (name, LOAD_PROC) == 0)
@@ -400,7 +403,7 @@
run_mode = param[0].data.d_int32;
image_ID = load_image (param[1].data.d_string,
- run_mode == GIMP_RUN_INTERACTIVE);
+ run_mode == GIMP_RUN_INTERACTIVE, &error);
if (image_ID != -1)
{
@@ -411,6 +414,13 @@
else
{
status = GIMP_PDB_EXECUTION_ERROR;
+
+ if (error)
+ {
+ *nreturn_vals = 2;
+ values[1].type = GIMP_PDB_STRING;
+ values[1].data.d_string = error->message;
+ }
}
}
else if (strcmp (name, SAVE_PROC) == 0 ||
@@ -436,6 +446,7 @@
GIMP_EXPORT_CAN_HANDLE_GRAY |
GIMP_EXPORT_CAN_HANDLE_INDEXED |
GIMP_EXPORT_CAN_HANDLE_ALPHA));
+
if (export == GIMP_EXPORT_CANCEL)
{
*nreturn_vals = 1;
@@ -505,7 +516,9 @@
if (pngvals.compression_level < 0 ||
pngvals.compression_level > 9)
- status = GIMP_PDB_CALLING_ERROR;
+ {
+ status = GIMP_PDB_CALLING_ERROR;
+ }
}
}
break;
@@ -524,13 +537,20 @@
if (status == GIMP_PDB_SUCCESS)
{
if (save_image (param[3].data.d_string,
- image_ID, drawable_ID, orig_image_ID))
+ image_ID, drawable_ID, orig_image_ID, &error))
{
gimp_set_data (SAVE_PROC, &pngvals, sizeof (pngvals));
}
else
{
status = GIMP_PDB_EXECUTION_ERROR;
+
+ if (error)
+ {
+ *nreturn_vals = 2;
+ values[1].type = GIMP_PDB_STRING;
+ values[1].data.d_string = error->message;
+ }
}
}
@@ -646,8 +666,9 @@
*/
static gint32
-load_image (const gchar *filename,
- gboolean interactive)
+load_image (const gchar *filename,
+ gboolean interactive,
+ GError **error)
{
int i, /* Looping var */
trns, /* Transparency present */
@@ -683,8 +704,9 @@
if (setjmp (pp->jmpbuf))
{
- g_message (_("Error while reading '%s'. File corrupted?"),
- gimp_filename_to_utf8 (filename));
+ g_set_error (error, 0, 0,
+ _("Error while reading '%s'. File corrupted?"),
+ gimp_filename_to_utf8 (filename));
return image;
}
@@ -700,8 +722,9 @@
if (fp == NULL)
{
- g_message (_("Could not open '%s' for reading: %s"),
- gimp_filename_to_utf8 (filename), g_strerror (errno));
+ g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
+ _("Could not open '%s' for reading: %s"),
+ gimp_filename_to_utf8 (filename), g_strerror (errno));
return -1;
}
@@ -810,17 +833,20 @@
image_type = GIMP_INDEXED;
layer_type = GIMP_INDEXED_IMAGE;
break;
- default: /* Aie! Unknown type */
- g_message (_("Unknown color model in PNG file '%s'."),
- gimp_filename_to_utf8 (filename));
+
+ default: /* Aie! Unknown type */
+ g_set_error (error, 0, 0,
+ _("Unknown color model in PNG file '%s'."),
+ gimp_filename_to_utf8 (filename));
return -1;
}
image = gimp_image_new (info->width, info->height, image_type);
if (image == -1)
{
- g_message ("Could not create new image for '%s'",
- gimp_filename_to_utf8 (filename));
+ g_set_error (error, 0, 0,
+ "Could not create new image for '%s': %s",
+ gimp_filename_to_utf8 (filename), gimp_get_pdb_error ());
return -1;
}
@@ -1127,6 +1153,7 @@
gimp_pixel_rgn_set_rect (&pixel_rgn, pixel, 0, begin,
drawable->width, num);
}
+
g_free (pixel);
}
@@ -1137,7 +1164,7 @@
gimp_drawable_flush (drawable);
gimp_drawable_detach (drawable);
- return (image);
+ return image;
}
@@ -1146,10 +1173,11 @@
*/
static gboolean
-save_image (const gchar *filename,
- gint32 image_ID,
- gint32 drawable_ID,
- gint32 orig_image_ID)
+save_image (const gchar *filename,
+ gint32 image_ID,
+ gint32 drawable_ID,
+ gint32 orig_image_ID,
+ GError **error)
{
gint i, k, /* Looping vars */
bpp = 0, /* Bytes per pixel */
@@ -1227,8 +1255,9 @@
if (setjmp (pp->jmpbuf))
{
- g_message (_("Error while saving '%s'. Could not save image."),
- gimp_filename_to_utf8 (filename));
+ g_set_error (error, 0, 0,
+ _("Error while saving '%s'. Could not save image."),
+ gimp_filename_to_utf8 (filename));
return FALSE;
}
@@ -1242,8 +1271,9 @@
fp = g_fopen (filename, "wb");
if (fp == NULL)
{
- g_message (_("Could not open '%s' for writing: %s"),
- gimp_filename_to_utf8 (filename), g_strerror (errno));
+ g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
+ _("Could not open '%s' for writing: %s"),
+ gimp_filename_to_utf8 (filename), g_strerror (errno));
return FALSE;
}
@@ -1319,7 +1349,8 @@
break;
default:
- g_message ("Image type can't be saved as PNG");
+ g_set_error (error, 0, 0,
+ "%s", _("Image type can't be saved as PNG"));
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]