[gimp/gimp-2-8] app: return a GError when flattening the image failed
- From: Simon Budig <simon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-8] app: return a GError when flattening the image failed
- Date: Fri, 9 Aug 2013 19:40:03 +0000 (UTC)
commit 1ecc25a260aac95344c984e4014e429812cafec3
Author: Michael Natterer <mitch gimp org>
Date: Fri Aug 9 21:31:55 2013 +0200
app: return a GError when flattening the image failed
(cherry picked from commit c32c1208b09c3383435fd038a3bd21932d663a47)
app/actions/image-commands.c | 13 ++++++++++++-
app/core/gimpimage-merge.c | 12 +++++++++---
app/core/gimpimage-merge.h | 3 ++-
app/pdb/image-cmds.c | 2 +-
tools/pdbgen/pdb/image.pdb | 2 +-
5 files changed, 25 insertions(+), 7 deletions(-)
---
diff --git a/app/actions/image-commands.c b/app/actions/image-commands.c
index 2526b1e..3b45ac8 100644
--- a/app/actions/image-commands.c
+++ b/app/actions/image-commands.c
@@ -487,9 +487,20 @@ image_flatten_image_cmd_callback (GtkAction *action,
gpointer data)
{
GimpImage *image;
+ GtkWidget *widget;
+ GError *error = NULL;
return_if_no_image (image, data);
+ return_if_no_widget (widget, data);
+
+ if (! gimp_image_flatten (image, action_data_get_context (data), &error))
+ {
+ gimp_message_literal (image->gimp,
+ G_OBJECT (widget), GIMP_MESSAGE_WARNING,
+ error->message);
+ g_clear_error (&error);
+ return;
+ }
- gimp_image_flatten (image, action_data_get_context (data));
gimp_image_flush (image);
}
diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c
index 5038c93..effde79 100644
--- a/app/core/gimpimage-merge.c
+++ b/app/core/gimpimage-merge.c
@@ -161,8 +161,9 @@ gimp_image_merge_visible_layers (GimpImage *image,
}
GimpLayer *
-gimp_image_flatten (GimpImage *image,
- GimpContext *context)
+gimp_image_flatten (GimpImage *image,
+ GimpContext *context,
+ GError **error)
{
GList *list;
GSList *merge_list = NULL;
@@ -170,6 +171,7 @@ gimp_image_flatten (GimpImage *image,
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
for (list = gimp_image_get_layer_iter (image);
list;
@@ -207,9 +209,13 @@ gimp_image_flatten (GimpImage *image,
gimp_image_undo_group_end (image);
gimp_unset_busy (image->gimp);
+
+ return layer;
}
- return gimp_image_get_active_layer (image);
+ g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
+ _("Cannot flatten an image without any visible layer."));
+ return NULL;
}
GimpLayer *
diff --git a/app/core/gimpimage-merge.h b/app/core/gimpimage-merge.h
index 35bdce1..f5031ef 100644
--- a/app/core/gimpimage-merge.h
+++ b/app/core/gimpimage-merge.h
@@ -33,7 +33,8 @@ GimpLayer * gimp_image_merge_group_layer (GimpImage *image,
GimpGroupLayer *group);
GimpLayer * gimp_image_flatten (GimpImage *image,
- GimpContext *context);
+ GimpContext *context,
+ GError **error);
GimpVectors * gimp_image_merge_visible_vectors (GimpImage *image,
GError **error);
diff --git a/app/pdb/image-cmds.c b/app/pdb/image-cmds.c
index 942e026..5c194a3 100644
--- a/app/pdb/image-cmds.c
+++ b/app/pdb/image-cmds.c
@@ -1404,7 +1404,7 @@ image_flatten_invoker (GimpProcedure *procedure,
if (success)
{
- layer = gimp_image_flatten (image, context);
+ layer = gimp_image_flatten (image, context, error);
if (! layer)
success = FALSE;
diff --git a/tools/pdbgen/pdb/image.pdb b/tools/pdbgen/pdb/image.pdb
index a84aea3..aca9e67 100644
--- a/tools/pdbgen/pdb/image.pdb
+++ b/tools/pdbgen/pdb/image.pdb
@@ -1028,7 +1028,7 @@ HELP
headers => [ qw("core/gimpimage-merge.h") ],
code => <<'CODE'
{
- layer = gimp_image_flatten (image, context);
+ layer = gimp_image_flatten (image, context, error);
if (! layer)
success = FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]