Commit dc3ac419 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

add the layer to the image before pasting to it. Fixes bug #132504.

2004-01-26  Michael Natterer  <mitch@gimp.org>

	* plug-ins/script-fu/scripts/unsharp-mask.scm: add the layer to
	the image before pasting to it. Fixes bug #132504.

	Fixed the underlying problem: make it impossible to attach
	floating selections to drawables which are not currently part of
	the image's layer or channel stacks.
	Also cleaned up image <-> floating_sel interaction:

	* app/core/gimplayer-floating-sel.[ch] (floating_sel_attach):
	added assertion that the drawable is part of the image (see below).
	Don't call gimp_image_floating_selection_changed(), it's emitted
	by gimp_image_add_layer() now.

	(floating_sel_remove)
	(floating_sel_anchor): don't emit "floating_selection_changed",
	it's emitted by gimp_image_remove_layer() now.

	(floating_sel_anchor): removed the fix for bug #132162 because
	gimp_image_remove_layer() behaves correctly now (see below).

	Renamed floating_sel_reset() to floating_sel_activate_drawable().
	Added g_return_if_fail() all over the place.

	* app/core/gimpimage.[ch]: added new function gimp_image_owns_item()
	which return TRUE if the passed item is part of the image.

	(gimp_image_add_layer): emit "floating_selection_changed" here if
	needed.

	(gimp_image_remove_layer): emit "floating_selection_changed" if
	needed, don't try to activate a layer if we called
	floating_sel_activate_drawable().
	This is the real fix for bug #132162.

	* app/core/gimpimage-undo-push.c (undo_pop_layer): apply the same
	fixes as to gimp_image_add,remove_layer(). Don't call
	gimp_drawable_invalidate_preview() on the previously active layer
	because that's done by gimp_image_set_active_layer() now.

	* app/xcf/xcf-load.c: remember the "floating_sel_drawable" in the
	XcfInfo struct and attach it *after* all layers and channels are
	loaded to avoid attaching the floating selection to an
	out-of-image drawable.

	* app/core/gimp-edit.c (gimp_edit_paste)
	* app/core/gimpdrawable-transform.c (gimp_drawable_transform_affine,
	gimp_drawable_transform_flip, gimp_drawable_transform_rotate)
	* app/core/gimpselection.c (gimp_selection_float)
	* app/text/gimptext-compat.c (text_render): added checks for
	gimp_image_owns_item() in all functions which can produce
	floating selections.

	* tools/pdbgen/pdb/edit.pdb
	* tools/pdbgen/pdb/floating_sel.pdb
	* tools/pdbgen/pdb/selection.pdb
	* tools/pdbgen/pdb/text_tool.pdb
	* tools/pdbgen/pdb/transform_tools.pdb: added checks for
	gimp_item_owns_image() and return an execution error if invoked
	with a drawable which is not part of the image.

	* app/pdb/edit_cmds.c
	* app/pdb/floating_sel_cmds.c
	* app/pdb/selection_cmds.c
	* app/pdb/text_tool_cmds.c
	* app/pdb/transform_tools_cmds.c: regenerated.
parent 71c94006
2004-01-26 Michael Natterer <mitch@gimp.org>
* plug-ins/script-fu/scripts/unsharp-mask.scm: add the layer to
the image before pasting to it. Fixes bug #132504.
Fixed the underlying problem: make it impossible to attach
floating selections to drawables which are not currently part of
the image's layer or channel stacks.
Also cleaned up image <-> floating_sel interaction:
* app/core/gimplayer-floating-sel.[ch] (floating_sel_attach):
added assertion that the drawable is part of the image (see below).
Don't call gimp_image_floating_selection_changed(), it's emitted
by gimp_image_add_layer() now.
(floating_sel_remove)
(floating_sel_anchor): don't emit "floating_selection_changed",
it's emitted by gimp_image_remove_layer() now.
(floating_sel_anchor): removed the fix for bug #132162 because
gimp_image_remove_layer() behaves correctly now (see below).
Renamed floating_sel_reset() to floating_sel_activate_drawable().
Added g_return_if_fail() all over the place.
* app/core/gimpimage.[ch]: added new function gimp_image_owns_item()
which return TRUE if the passed item is part of the image.
(gimp_image_add_layer): emit "floating_selection_changed" here if
needed.
(gimp_image_remove_layer): emit "floating_selection_changed" if
needed, don't try to activate a layer if we called
floating_sel_activate_drawable().
This is the real fix for bug #132162.
* app/core/gimpimage-undo-push.c (undo_pop_layer): apply the same
fixes as to gimp_image_add,remove_layer(). Don't call
gimp_drawable_invalidate_preview() on the previously active layer
because that's done by gimp_image_set_active_layer() now.
* app/xcf/xcf-load.c: remember the "floating_sel_drawable" in the
XcfInfo struct and attach it *after* all layers and channels are
loaded to avoid attaching the floating selection to an
out-of-image drawable.
* app/core/gimp-edit.c (gimp_edit_paste)
* app/core/gimpdrawable-transform.c (gimp_drawable_transform_affine,
gimp_drawable_transform_flip, gimp_drawable_transform_rotate)
* app/core/gimpselection.c (gimp_selection_float)
* app/text/gimptext-compat.c (text_render): added checks for
gimp_image_owns_item() in all functions which can produce
floating selections.
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/floating_sel.pdb
* tools/pdbgen/pdb/selection.pdb
* tools/pdbgen/pdb/text_tool.pdb
* tools/pdbgen/pdb/transform_tools.pdb: added checks for
gimp_item_owns_image() and return an execution error if invoked
with a drawable which is not part of the image.
* app/pdb/edit_cmds.c
* app/pdb/floating_sel_cmds.c
* app/pdb/selection_cmds.c
* app/pdb/text_tool_cmds.c
* app/pdb/transform_tools_cmds.c: regenerated.
2004-01-26 Michael Natterer <mitch@gimp.org>
* app/xcf/xcf-save.c (xcf_save_channel): store the correct offset
......@@ -99,6 +99,9 @@ gimp_edit_paste (GimpImage *gimage,
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (drawable == NULL || GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (drawable == NULL ||
gimp_image_owns_item (gimage,
GIMP_ITEM (drawable)), NULL);
g_return_val_if_fail (GIMP_IS_BUFFER (paste), NULL);
/* Make a new layer: if drawable == NULL,
......
......@@ -818,7 +818,8 @@ gimp_drawable_transform_affine (GimpDrawable *drawable,
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (gimp_image_owns_item (gimage, GIMP_ITEM (drawable)),
FALSE);
/* Start a transform undo group */
gimp_image_undo_group_start (gimage,
......@@ -874,7 +875,8 @@ gimp_drawable_transform_flip (GimpDrawable *drawable,
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (gimp_image_owns_item (gimage, GIMP_ITEM (drawable)),
FALSE);
/* Start a transform undo group */
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TRANSFORM, _("Flip"));
......@@ -941,7 +943,8 @@ gimp_drawable_transform_rotate (GimpDrawable *drawable,
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (gimp_image_owns_item (gimage, GIMP_ITEM (drawable)),
FALSE);
/* Start a transform undo group */
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TRANSFORM, _("Rotate"));
......@@ -1042,7 +1045,8 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (gimp_image_owns_item (gimage, GIMP_ITEM (drawable)),
FALSE);
if (new_layer)
{
......
......@@ -818,7 +818,8 @@ gimp_drawable_transform_affine (GimpDrawable *drawable,
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (gimp_image_owns_item (gimage, GIMP_ITEM (drawable)),
FALSE);
/* Start a transform undo group */
gimp_image_undo_group_start (gimage,
......@@ -874,7 +875,8 @@ gimp_drawable_transform_flip (GimpDrawable *drawable,
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (gimp_image_owns_item (gimage, GIMP_ITEM (drawable)),
FALSE);
/* Start a transform undo group */
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TRANSFORM, _("Flip"));
......@@ -941,7 +943,8 @@ gimp_drawable_transform_rotate (GimpDrawable *drawable,
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (gimp_image_owns_item (gimage, GIMP_ITEM (drawable)),
FALSE);
/* Start a transform undo group */
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TRANSFORM, _("Rotate"));
......@@ -1042,7 +1045,8 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (gimp_image_owns_item (gimage, GIMP_ITEM (drawable)),
FALSE);
if (new_layer)
{
......
......@@ -1505,9 +1505,6 @@ undo_pop_layer (GimpUndo *undo,
undo->size += gimp_object_get_memsize (GIMP_OBJECT (layer), NULL);
/* Make sure we're not caching any old selection info */
gimp_drawable_invalidate_boundary (GIMP_DRAWABLE (layer));
/* record the current position */
lu->prev_position = gimp_image_get_layer_index (undo->gimage, layer);
......@@ -1515,17 +1512,16 @@ undo_pop_layer (GimpUndo *undo,
undo->gimage->layer_stack = g_slist_remove (undo->gimage->layer_stack,
layer);
/* reset the gimage values */
if (gimp_layer_is_floating_sel (layer))
{
undo->gimage->floating_sel = NULL;
/* reset the old drawable */
floating_sel_reset (layer);
gimp_image_floating_selection_changed (undo->gimage);
}
/* activate the underlying drawable */
floating_sel_activate_drawable (layer);
if (layer == gimp_image_get_active_layer (undo->gimage))
gimp_image_floating_selection_changed (undo->gimage);
}
else if (layer == gimp_image_get_active_layer (undo->gimage))
{
if (lu->prev_layer)
{
......@@ -1557,10 +1553,6 @@ undo_pop_layer (GimpUndo *undo,
/* record the active layer */
lu->prev_layer = gimp_image_get_active_layer (undo->gimage);
/* hide the current selection--for all views */
if (lu->prev_layer)
gimp_drawable_invalidate_boundary (GIMP_DRAWABLE (lu->prev_layer));
/* if this is a floating selection, set the fs pointer */
if (gimp_layer_is_floating_sel (layer))
undo->gimage->floating_sel = layer;
......
......@@ -2093,6 +2093,43 @@ gimp_image_get_vectors (const GimpImage *gimage)
return gimage->vectors;
}
gboolean
gimp_image_owns_item (const GimpImage *gimage,
const GimpItem *item)
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
if (GIMP_IS_VECTORS (item))
{
return gimp_container_have (gimage->vectors, GIMP_OBJECT (item));
}
else if (GIMP_IS_LAYER_MASK (item))
{
GimpLayerMask *mask = GIMP_LAYER_MASK (item);
GimpLayer *layer = gimp_layer_mask_get_layer (mask);
if (gimp_layer_get_mask (layer) == mask)
return gimp_image_owns_item (gimage, GIMP_ITEM (layer));
return FALSE;
}
else if (GIMP_IS_SELECTION (item))
{
return GIMP_CHANNEL (item) == gimp_image_get_mask (gimage);
}
else if (GIMP_IS_CHANNEL (item))
{
return gimp_container_have (gimage->channels, GIMP_OBJECT (item));
}
else if (GIMP_IS_LAYER (item))
{
return gimp_container_have (gimage->layers, GIMP_OBJECT (item));
}
return FALSE;
}
GimpDrawable *
gimp_image_active_drawable (const GimpImage *gimage)
{
......@@ -2483,6 +2520,9 @@ gimp_image_add_layer (GimpImage *gimage,
if (old_has_alpha != gimp_image_has_alpha (gimage))
gimp_image_alpha_changed (gimage);
if (gimp_layer_is_floating_sel (layer))
gimp_image_floating_selection_changed (gimage);
return TRUE;
}
......@@ -2518,15 +2558,18 @@ gimp_image_remove_layer (GimpImage *gimage,
gimp_container_remove (gimage->layers, GIMP_OBJECT (layer));
gimage->layer_stack = g_slist_remove (gimage->layer_stack, layer);
/* If this was the floating selection, reset the fs pointer */
if (gimage->floating_sel == layer)
{
/* If this was the floating selection, reset the fs pointer
* and activate the underlying drawable
*/
gimage->floating_sel = NULL;
floating_sel_reset (layer);
}
floating_sel_activate_drawable (layer);
if (layer == active_layer)
gimp_image_floating_selection_changed (gimage);
}
else if (layer == active_layer)
{
if (gimage->layer_stack)
{
......
......@@ -379,6 +379,9 @@ GimpContainer * gimp_image_get_layers (const GimpImage *gimage);
GimpContainer * gimp_image_get_channels (const GimpImage *gimage);
GimpContainer * gimp_image_get_vectors (const GimpImage *gimage);
gboolean gimp_image_owns_item (const GimpImage *gimage,
const GimpItem *item);
GimpDrawable * gimp_image_active_drawable (const GimpImage *gimage);
GimpLayer * gimp_image_get_active_layer (const GimpImage *gimage);
GimpChannel * gimp_image_get_active_channel (const GimpImage *gimage);
......
......@@ -47,11 +47,18 @@ floating_sel_attach (GimpLayer *layer,
GimpImage *gimage;
GimpLayer *floating_sel;
if (! (gimage = gimp_item_get_image (GIMP_ITEM (drawable))))
return;
g_return_if_fail (GIMP_IS_LAYER (layer));
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (drawable != GIMP_DRAWABLE (layer));
g_return_if_fail (gimp_item_get_image (GIMP_ITEM (layer)) ==
gimp_item_get_image (GIMP_ITEM (drawable)));
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_return_if_fail (gimp_image_owns_item (gimage, GIMP_ITEM (drawable)));
/* If there is already a floating selection, anchor it */
if (gimage->floating_sel != NULL)
if (gimage->floating_sel)
{
floating_sel = gimage->floating_sel;
floating_sel_anchor (gimp_image_floating_sel (gimage));
......@@ -75,8 +82,6 @@ floating_sel_attach (GimpLayer *layer,
/* store the affected area from the drawable in the backing store */
floating_sel_rigor (layer, TRUE);
gimp_image_floating_selection_changed (gimage);
}
void
......@@ -84,8 +89,10 @@ floating_sel_remove (GimpLayer *layer)
{
GimpImage *gimage;
if (! (gimage = gimp_item_get_image (GIMP_ITEM (layer->fs.drawable))))
return;
g_return_if_fail (GIMP_IS_LAYER (layer));
g_return_if_fail (gimp_layer_is_floating_sel (layer));
gimage = gimp_item_get_image (GIMP_ITEM (layer->fs.drawable));
/* store the affected area from the drawable in the backing store */
floating_sel_relax (layer, TRUE);
......@@ -98,8 +105,6 @@ floating_sel_remove (GimpLayer *layer)
/* remove the layer from the gimage */
gimp_image_remove_layer (gimage, layer);
gimp_image_floating_selection_changed (gimage);
}
void
......@@ -108,8 +113,10 @@ floating_sel_anchor (GimpLayer *layer)
GimpImage *gimage;
GimpDrawable *drawable;
if (! (gimage = gimp_item_get_image (GIMP_ITEM (layer))))
return;
g_return_if_fail (GIMP_IS_LAYER (layer));
g_return_if_fail (gimp_layer_is_floating_sel (layer));
gimage = gimp_item_get_image (GIMP_ITEM (layer));
if (! gimp_layer_is_floating_sel (layer))
{
......@@ -142,53 +149,38 @@ floating_sel_anchor (GimpLayer *layer)
/* remove the floating selection */
gimp_image_remove_layer (gimage, layer);
/* activate the drawable the floating selection was attached to */
if (GIMP_IS_LAYER_MASK (drawable))
{
GimpLayerMask *mask = GIMP_LAYER_MASK (drawable);
gimp_image_set_active_layer (gimage, gimp_layer_mask_get_layer (mask));
}
else if (GIMP_IS_CHANNEL (drawable))
{
gimp_image_set_active_channel (gimage, GIMP_CHANNEL (drawable));
}
else
{
gimp_image_set_active_layer (gimage, GIMP_LAYER (drawable));
}
/* end the group undo */
gimp_image_undo_group_end (gimage);
/* invalidate the boundaries */
gimp_drawable_invalidate_boundary (GIMP_DRAWABLE (gimp_image_get_mask (gimage)));
gimp_image_floating_selection_changed (gimage);
}
void
floating_sel_reset (GimpLayer *layer)
floating_sel_activate_drawable (GimpLayer *layer)
{
GimpImage *gimage;
if (! (gimage = gimp_item_get_image (GIMP_ITEM (layer))))
return;
g_return_if_fail (GIMP_IS_LAYER (layer));
g_return_if_fail (gimp_layer_is_floating_sel (layer));
gimage = gimp_item_get_image (GIMP_ITEM (layer));
/* set the underlying drawable to active */
if (GIMP_IS_LAYER (layer->fs.drawable))
if (GIMP_IS_LAYER_MASK (layer->fs.drawable))
{
gimp_image_set_active_layer (gimage, GIMP_LAYER (layer->fs.drawable));
}
else if (GIMP_IS_LAYER_MASK (layer->fs.drawable))
{
gimp_image_set_active_layer (gimage,
GIMP_LAYER_MASK (layer->fs.drawable)->layer);
GimpLayerMask *mask = GIMP_LAYER_MASK (layer->fs.drawable);
gimp_image_set_active_layer (gimage, gimp_layer_mask_get_layer (mask));
}
else if (GIMP_IS_CHANNEL (layer->fs.drawable))
{
gimp_image_set_active_channel (gimage, GIMP_CHANNEL (layer->fs.drawable));
}
else
{
gimp_image_set_active_layer (gimage, GIMP_LAYER (layer->fs.drawable));
}
}
void
......@@ -200,6 +192,7 @@ floating_sel_to_layer (GimpLayer *layer)
gint width, height;
g_return_if_fail (GIMP_IS_LAYER (layer));
g_return_if_fail (gimp_layer_is_floating_sel (layer));
item = GIMP_ITEM (layer);
......@@ -262,6 +255,9 @@ floating_sel_store (GimpLayer *layer,
gint offx, offy;
gint x1, y1, x2, y2;
g_return_if_fail (GIMP_IS_LAYER (layer));
g_return_if_fail (gimp_layer_is_floating_sel (layer));
/* Check the backing store & make sure it has the correct dimensions */
if ((tile_manager_width (layer->fs.backing_store) !=
gimp_item_width (GIMP_ITEM(layer))) ||
......@@ -323,6 +319,9 @@ floating_sel_restore (GimpLayer *layer,
gint offx, offy;
gint x1, y1, x2, y2;
g_return_if_fail (GIMP_IS_LAYER (layer));
g_return_if_fail (gimp_layer_is_floating_sel (layer));
/* What this function does is "uncover" the specified area in the
* drawable that this floating selection obscures. We do this so
* that either the floating selection can be removed or it can be
......@@ -362,6 +361,9 @@ void
floating_sel_rigor (GimpLayer *layer,
gboolean push_undo)
{
g_return_if_fail (GIMP_IS_LAYER (layer));
g_return_if_fail (gimp_layer_is_floating_sel (layer));
/* store the affected area from the drawable in the backing store */
floating_sel_store (layer,
GIMP_ITEM (layer)->offset_x,
......@@ -380,6 +382,9 @@ void
floating_sel_relax (GimpLayer *layer,
gboolean push_undo)
{
g_return_if_fail (GIMP_IS_LAYER (layer));
g_return_if_fail (gimp_layer_is_floating_sel (layer));
/* restore the contents of drawable the floating layer is attached to */
if (layer->fs.initial == FALSE)
floating_sel_restore (layer,
......@@ -405,14 +410,15 @@ floating_sel_composite (GimpLayer *layer,
{
PixelRegion fsPR;
GimpImage *gimage;
GimpLayer *d_layer;
GimpLayer *d_layer = NULL;
gint preserve_trans;
gint active[MAX_CHANNELS];
gint offx, offy;
gint x1, y1, x2, y2;
gint i;
d_layer = NULL;
g_return_if_fail (GIMP_IS_LAYER (layer));
g_return_if_fail (gimp_layer_is_floating_sel (layer));
if (! (gimage = gimp_item_get_image (GIMP_ITEM (layer))))
return;
......@@ -512,6 +518,10 @@ floating_sel_boundary (GimpLayer *layer,
PixelRegion bPR;
gint i;
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
g_return_val_if_fail (gimp_layer_is_floating_sel (layer), NULL);
g_return_val_if_fail (n_segs != NULL, NULL);
if (layer->fs.boundary_known == FALSE)
{
if (layer->fs.segs)
......@@ -548,6 +558,9 @@ floating_sel_boundary (GimpLayer *layer,
void
floating_sel_invalidate (GimpLayer *layer)
{
g_return_if_fail (GIMP_IS_LAYER (layer));
g_return_if_fail (gimp_layer_is_floating_sel (layer));
/* Invalidate the attached-to drawable's preview */
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (layer->fs.drawable));
......
......@@ -20,35 +20,35 @@
#define __GIMP_LAYER_FLOATING_SEL_H__
void floating_sel_attach (GimpLayer *layer,
GimpDrawable *drawable);
void floating_sel_remove (GimpLayer *layer);
void floating_sel_anchor (GimpLayer *layer);
void floating_sel_reset (GimpLayer *layer);
void floating_sel_to_layer (GimpLayer *layer);
void floating_sel_store (GimpLayer *layer,
gint x,
gint y,
gint w,
gint h);
void floating_sel_restore (GimpLayer *layer,
gint x,
gint y,
gint w,
gint h);
void floating_sel_rigor (GimpLayer *layer,
gboolean push_undo);
void floating_sel_relax (GimpLayer *layer,
gboolean push_undo);
void floating_sel_composite (GimpLayer *layer,
gint x,
gint y,
gint w,
gint h,
gboolean push_undo);
const BoundSeg * floating_sel_boundary (GimpLayer *layer,
gint *n_segs);
void floating_sel_invalidate (GimpLayer *layer);
void floating_sel_attach (GimpLayer *layer,
GimpDrawable *drawable);
void floating_sel_remove (GimpLayer *layer);
void floating_sel_anchor (GimpLayer *layer);
void floating_sel_activate_drawable (GimpLayer *layer);
void floating_sel_to_layer (GimpLayer *layer);
void floating_sel_store (GimpLayer *layer,
gint x,
gint y,
gint w,
gint h);
void floating_sel_restore (GimpLayer *layer,
gint x,
gint y,
gint w,
gint h);
void floating_sel_rigor (GimpLayer *layer,
gboolean push_undo);
void floating_sel_relax (GimpLayer *layer,
gboolean push_undo);
void floating_sel_composite (GimpLayer *layer,
gint x,
gint y,
gint w,
gint h,
gboolean push_undo);
const BoundSeg * floating_sel_boundary (GimpLayer *layer,
gint *n_segs);
void floating_sel_invalidate (GimpLayer *layer);
#endif /* __GIMP_LAYER_FLOATING_SEL_H__ */
......@@ -808,6 +808,9 @@ gimp_selection_float (GimpChannel *selection,
gimage = gimp_item_get_image (GIMP_ITEM (selection));
g_return_val_if_fail (gimp_image_owns_item (gimage, GIMP_ITEM (drawable)),
NULL);
/* Make sure there is a region to float... */
non_empty = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
if (! non_empty || (x2 - x1) == 0 || (y2 - y1) == 0)
......
......@@ -162,7 +162,6 @@ edit_paste_invoker (Gimp *gimp,
GimpDrawable *drawable;
gboolean paste_into;
GimpLayer *layer = NULL;
GimpImage *gimage;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_DRAWABLE (drawable))
......@@ -172,9 +171,17 @@ edit_paste_invoker (Gimp *gimp,
if (success)
{
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
layer = gimp_edit_paste (gimage, drawable, gimp->global_buffer, paste_into, -1, -1, -1, -1);
success = layer != NULL;
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
success = gimp_image_owns_item (gimage, GIMP_ITEM (drawable));
if (success)
{
layer = gimp_edit_paste (gimage, drawable, gimp->global_buffer,
paste_into, -1, -1, -1, -1);
if (! layer)
success = FALSE;
}
}
return_args = procedural_db_return_args (&edit_paste_proc, success);
......
......@@ -29,6 +29,7 @@
#include "procedural_db.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimplayer-floating-sel.h"
#include "core/gimplayer.h"
......@@ -208,7 +209,14 @@ floating_sel_attach_invoker (Gimp *gimp,
success = FALSE;
if (success)
floating_sel_attach (layer, drawable);
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
if (gimp_image_owns_item (gimage, GIMP_ITEM (drawable)))
floating_sel_attach (layer, drawable);
else
success = FALSE;
}
return procedural_db_return_args (&floating_sel_attach_proc, success);
}
......
......@@ -369,12 +369,17 @@ selection_float_invoker (Gimp *gimp,
if (success)
{
GimpImage *gimage;
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
success = gimp_image_owns_item (gimage, GIMP_ITEM (drawable));
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
layer = gimp_selection_float (gimp_image_get_mask (gimage),
drawable, TRUE, offx, offy);
success = layer != NULL;
if (success)
{
layer = gimp_selection_float (gimp_image_get_mask (gimage),
drawable, TRUE, offx, offy);
if (! layer)
success = FALSE;
}
}
return_args = procedural_db_return_args (&selection_float_proc, success);
......
......@@ -68,7 +68,6 @@ text_fontname_invoker (Gimp *gimp,
gint32 size_type;
gchar *fontname;
GimpLayer *text_layer = NULL;
gchar *real_fontname;
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (gimage))
......@@ -104,14 +103,20 @@ text_fontname_invoker (Gimp *gimp,
if (success)
{
real_fontname = g_strdup_printf ("%s %d", fontname, (gint) size);
text_layer = text_render (gimage, drawable, x, y, real_fontname, text,
border, antialias);
if (text_layer == NULL)
if (drawable && ! gimp_image_owns_item (gimage, GIMP_ITEM (drawable)))
success = FALSE;
g_free (real_fontname);
if (success)
{
gchar *real_fontname = g_strdup_printf ("%s %d", fontname, (gint) size);
text_layer = text_render (gimage, drawable, x, y, real_fontname, text,
border, antialias);
if (text_layer == NULL)
success = FALSE;
g_free (real_fontname);
}
}
return_args = procedural_db_return_args (&text_fontname_proc, success);
......@@ -345,7 +350,6 @@ text_invoker (Gimp *gimp,
gchar *registry;
gchar *encoding;
GimpLayer *text_layer = NULL;
gchar *real_fontname;
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (gimage))
......@@ -409,14 +413,20 @@ text_invoker (Gimp *gimp,
if (success)
{
real_fontname = g_strdup_printf ("%s %d", family, (gint) size);
text_layer = text_render (gimage, drawable, x, y, real_fontname, text,
border, antialias);
if (text_layer == NULL)
if (drawable && ! gimp_image_owns_item (gimage, GIMP_ITEM (drawable)))
success = FALSE;
g_free (real_fontname);
if (success)
{
gchar *real_fontname = g_strdup_printf ("%s %d", family, (gint) size);
text_layer = text_render (gimage, drawable, x, y, real_fontname, text,
border, antialias);
if (text_layer == NULL)
success = FALSE;
g_free (real_fontname);
}
}
return_args = procedural_db_return_args (&text_proc, success);
......
......@@ -33,6 +33,7 @@
#include "core/gimp.h"
#include "core/gimpdrawable-transform.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"