mirror of https://github.com/GNOME/gimp.git
Add GError reporting to gimp_image_merge_down()
- turn g_return_if_fail() of more complex conditions into errors. - change PDB wrapper accordingly instead of adding a ton of conditions there.
This commit is contained in:
parent
d91a89e157
commit
d37dc64b16
|
@ -501,7 +501,7 @@ layers_merge_down_cmd_callback (GtkAction *action,
|
|||
return_if_no_layer (image, layer, data);
|
||||
|
||||
gimp_image_merge_down (image, layer, action_data_get_context (data),
|
||||
GIMP_EXPAND_AS_NECESSARY);
|
||||
GIMP_EXPAND_AS_NECESSARY, NULL);
|
||||
gimp_image_flush (image);
|
||||
}
|
||||
|
||||
|
|
|
@ -177,7 +177,8 @@ GimpLayer *
|
|||
gimp_image_merge_down (GimpImage *image,
|
||||
GimpLayer *current_layer,
|
||||
GimpContext *context,
|
||||
GimpMergeType merge_type)
|
||||
GimpMergeType merge_type,
|
||||
GError **error)
|
||||
{
|
||||
GimpLayer *layer;
|
||||
GList *list;
|
||||
|
@ -187,9 +188,15 @@ gimp_image_merge_down (GimpImage *image,
|
|||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_LAYER (current_layer), NULL);
|
||||
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (current_layer)), NULL);
|
||||
g_return_val_if_fail (gimp_viewable_get_children (GIMP_VIEWABLE (current_layer)) == NULL,
|
||||
NULL);
|
||||
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
if (gimp_viewable_get_children (GIMP_VIEWABLE (current_layer)))
|
||||
{
|
||||
g_set_error_literal (error, 0, 0,
|
||||
_("Cannot merge down a group layer."));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (list = gimp_item_get_container_iter (GIMP_ITEM (current_layer));
|
||||
list;
|
||||
|
@ -209,14 +216,25 @@ gimp_image_merge_down (GimpImage *image,
|
|||
|
||||
if (gimp_item_get_visible (GIMP_ITEM (layer)))
|
||||
{
|
||||
g_return_val_if_fail (! gimp_item_get_lock_content (GIMP_ITEM (layer)),
|
||||
NULL);
|
||||
if (gimp_item_get_lock_content (GIMP_ITEM (layer)))
|
||||
{
|
||||
g_set_error_literal (error, 0, 0,
|
||||
_("The layer to merge down to is locked."));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
merge_list = g_slist_append (NULL, layer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! merge_list)
|
||||
{
|
||||
g_set_error_literal (error, 0, 0,
|
||||
_("There is no visible layer to merge down to."));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
merge_list = g_slist_prepend (merge_list, current_layer);
|
||||
|
||||
gimp_set_busy (image->gimp);
|
||||
|
|
|
@ -26,7 +26,8 @@ GimpLayer * gimp_image_merge_visible_layers (GimpImage *image,
|
|||
GimpLayer * gimp_image_merge_down (GimpImage *image,
|
||||
GimpLayer *current_layer,
|
||||
GimpContext *context,
|
||||
GimpMergeType merge_type);
|
||||
GimpMergeType merge_type,
|
||||
GError **error);
|
||||
GimpLayer * gimp_image_flatten (GimpImage *image,
|
||||
GimpContext *context);
|
||||
GimpVectors * gimp_image_merge_visible_vectors (GimpImage *image,
|
||||
|
|
|
@ -1508,11 +1508,17 @@ image_merge_down_invoker (GimpProcedure *procedure,
|
|||
|
||||
if (success)
|
||||
{
|
||||
layer = gimp_image_merge_down (image, merge_layer, context, merge_type);
|
||||
if (gimp_pdb_item_is_attached (GIMP_ITEM (merge_layer), FALSE, error))
|
||||
{
|
||||
layer = gimp_image_merge_down (image, merge_layer, context, merge_type,
|
||||
error);
|
||||
|
||||
if (! layer)
|
||||
success = FALSE;
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
|
|
@ -941,10 +941,16 @@ HELP
|
|||
headers => [ qw("core/gimpimage-merge.h") ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
layer = gimp_image_merge_down (image, merge_layer, context, merge_type);
|
||||
if (gimp_pdb_item_is_attached (GIMP_ITEM (merge_layer), FALSE, error))
|
||||
{
|
||||
layer = gimp_image_merge_down (image, merge_layer, context, merge_type,
|
||||
error);
|
||||
|
||||
if (! layer)
|
||||
success = FALSE;
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
CODE
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue