Commit 0d5df419 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/core/gimpchannel-select.c app/core/gimpchannel.c

2004-11-16  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpchannel-select.c
	* app/core/gimpchannel.c
	* app/core/gimpdrawable-desaturate.c
	* app/core/gimpdrawable-equalize.c
	* app/core/gimpdrawable-histogram.c
	* app/core/gimpdrawable-invert.c
	* app/core/gimpdrawable-levels.c
	* app/core/gimpdrawable-offset.c
	* app/core/gimpdrawable-stroke.c
	* app/core/gimpdrawable-transform.c
	* app/core/gimpdrawable.c
	* app/core/gimpitem-linked.c
	* app/core/gimpitem.c
	* app/core/gimplayer.c
	* app/core/gimpselection.c
	* app/paint/gimppaintcore-stroke.c
	* app/text/gimptextlayer.c: in all functions which somehow
	(explicitely or implicitely) touch undo, either g_return_if_fail()
	on gimp_item_is_attached() or simply don't push an undo step if
	feasible (e.g. for simple stuff like layer opacity).

	* tools/pdbgen/pdb/color.pdb
	* tools/pdbgen/pdb/drawable.pdb
	* tools/pdbgen/pdb/image.pdb
	* tools/pdbgen/pdb/layer.pdb
	* tools/pdbgen/pdb/paint_tools.pdb: let PDB wrappers fail
	accordingly so they don't run into the assertions added above.

	* app/pdb/color_cmds.c
	* app/pdb/drawable_cmds.c
	* app/pdb/image_cmds.c
	* app/pdb/layer_cmds.c
	* app/pdb/paint_tools_cmds.c: regenerated.
parent d4bf381c
2004-11-16 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel-select.c
* app/core/gimpchannel.c
* app/core/gimpdrawable-desaturate.c
* app/core/gimpdrawable-equalize.c
* app/core/gimpdrawable-histogram.c
* app/core/gimpdrawable-invert.c
* app/core/gimpdrawable-levels.c
* app/core/gimpdrawable-offset.c
* app/core/gimpdrawable-stroke.c
* app/core/gimpdrawable-transform.c
* app/core/gimpdrawable.c
* app/core/gimpitem-linked.c
* app/core/gimpitem.c
* app/core/gimplayer.c
* app/core/gimpselection.c
* app/paint/gimppaintcore-stroke.c
* app/text/gimptextlayer.c: in all functions which somehow
(explicitely or implicitely) touch undo, either g_return_if_fail()
on gimp_item_is_attached() or simply don't push an undo step if
feasible (e.g. for simple stuff like layer opacity).
* tools/pdbgen/pdb/color.pdb
* tools/pdbgen/pdb/drawable.pdb
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/layer.pdb
* tools/pdbgen/pdb/paint_tools.pdb: let PDB wrappers fail
accordingly so they don't run into the assertions added above.
* app/pdb/color_cmds.c
* app/pdb/drawable_cmds.c
* app/pdb/image_cmds.c
* app/pdb/layer_cmds.c
* app/pdb/paint_tools_cmds.c: regenerated.
2004-11-16 Sven Neumann <sven@gimp.org>
* app/actions/file-commands.c
......
......@@ -145,6 +145,7 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
guchar bg_color[MAX_CHANNELS];
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (orig_tiles != NULL, NULL);
g_return_val_if_fail (matrix != NULL, NULL);
......@@ -152,8 +153,6 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
m = *matrix;
inv = *matrix;
......@@ -479,13 +478,12 @@ gimp_drawable_transform_tiles_flip (GimpDrawable *drawable,
gint i;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (orig_tiles != NULL, NULL);
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
orig_width = tile_manager_width (orig_tiles);
orig_height = tile_manager_height (orig_tiles);
orig_bpp = tile_manager_bpp (orig_tiles);
......@@ -642,13 +640,12 @@ gimp_drawable_transform_tiles_rotate (GimpDrawable *drawable,
gint i, j, k;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (orig_tiles != NULL, NULL);
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
orig_width = tile_manager_width (orig_tiles);
orig_height = tile_manager_height (orig_tiles);
orig_bpp = tile_manager_bpp (orig_tiles);
......@@ -858,8 +855,8 @@ gimp_drawable_transform_affine (GimpDrawable *drawable,
gboolean success = FALSE;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
g_return_val_if_fail (matrix != NULL, FALSE);
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), FALSE);
......@@ -922,8 +919,8 @@ gimp_drawable_transform_flip (GimpDrawable *drawable,
gboolean success = FALSE;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
......@@ -1003,8 +1000,8 @@ gimp_drawable_transform_rotate (GimpDrawable *drawable,
gboolean success = FALSE;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
......@@ -1068,13 +1065,12 @@ gimp_drawable_transform_cut (GimpDrawable *drawable,
TileManager *tiles;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (new_layer != NULL, NULL);
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
/* extract the selected mask if there is a selection */
if (! gimp_channel_is_empty (gimp_image_get_mask (gimage)))
{
......
......@@ -51,6 +51,7 @@ gimp_channel_select_rectangle (GimpChannel *channel,
gdouble feather_radius_y)
{
g_return_if_fail (GIMP_IS_CHANNEL (channel));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
gimp_channel_push_undo (channel, _("Rect Select"));
......@@ -101,6 +102,7 @@ gimp_channel_select_ellipse (GimpChannel *channel,
gdouble feather_radius_y)
{
g_return_if_fail (GIMP_IS_CHANNEL (channel));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
gimp_channel_push_undo (channel, _("Ellipse Select"));
......@@ -158,6 +160,7 @@ gimp_channel_select_scan_convert (GimpChannel *channel,
GimpChannel *add_on;
g_return_if_fail (GIMP_IS_CHANNEL (channel));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
g_return_if_fail (undo_desc != NULL);
g_return_if_fail (scan_convert != NULL);
......@@ -200,6 +203,7 @@ gimp_channel_select_polygon (GimpChannel *channel,
GimpScanConvert *scan_convert;
g_return_if_fail (GIMP_IS_CHANNEL (channel));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
g_return_if_fail (undo_desc != NULL);
scan_convert = gimp_scan_convert_new ();
......@@ -228,6 +232,7 @@ gimp_channel_select_vectors (GimpChannel *channel,
gboolean coords_added = FALSE;
g_return_if_fail (GIMP_IS_CHANNEL (channel));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
g_return_if_fail (undo_desc != NULL);
g_return_if_fail (GIMP_IS_VECTORS (vectors));
......@@ -288,6 +293,7 @@ gimp_channel_select_channel (GimpChannel *channel,
gdouble feather_radius_y)
{
g_return_if_fail (GIMP_IS_CHANNEL (channel));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
g_return_if_fail (undo_desc != NULL);
g_return_if_fail (GIMP_IS_CHANNEL (add_on));
......@@ -299,11 +305,9 @@ gimp_channel_select_channel (GimpChannel *channel,
if (feather || op == GIMP_CHANNEL_OP_INTERSECT)
{
GimpItem *item;
GimpItem *item = GIMP_ITEM (channel);
GimpChannel *add_on2;
item = GIMP_ITEM (channel);
add_on2 = gimp_channel_new_mask (gimp_item_get_image (item),
gimp_item_width (item),
gimp_item_height (item));
......@@ -339,6 +343,7 @@ gimp_channel_select_alpha (GimpChannel *channel,
gint off_x, off_y;
g_return_if_fail (GIMP_IS_CHANNEL (channel));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
item = GIMP_ITEM (channel);
......@@ -388,6 +393,7 @@ gimp_channel_select_component (GimpChannel *channel,
gchar *undo_desc;
g_return_if_fail (GIMP_IS_CHANNEL (channel));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
......@@ -435,6 +441,7 @@ gimp_channel_select_fuzzy (GimpChannel *channel,
gint add_on_y = 0;
g_return_if_fail (GIMP_IS_CHANNEL (channel));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
item = GIMP_ITEM (channel);
......@@ -478,6 +485,7 @@ gimp_channel_select_by_color (GimpChannel *channel,
gint add_on_y = 0;
g_return_if_fail (GIMP_IS_CHANNEL (channel));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (color != NULL);
......
......@@ -1520,13 +1520,12 @@ gimp_channel_set_color (GimpChannel *channel,
if (gimp_rgba_distance (&channel->color, color) > 0.0001)
{
if (push_undo)
if (push_undo && gimp_item_is_attached (GIMP_ITEM (channel)))
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (channel));
if (gimage)
gimp_image_undo_push_channel_color (gimage, _("Set Channel Color"),
channel);
gimp_image_undo_push_channel_color (gimage, _("Set Channel Color"),
channel);
}
channel->color = *color;
......@@ -1569,13 +1568,12 @@ gimp_channel_set_opacity (GimpChannel *channel,
if (channel->color.a != opacity)
{
if (push_undo)
if (push_undo && gimp_item_is_attached (GIMP_ITEM (channel)))
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (channel));
if (gimage)
gimp_image_undo_push_channel_color (gimage, _("Set Channel Opacity"),
channel);
gimp_image_undo_push_channel_color (gimage, _("Set Channel Opacity"),
channel);
}
channel->color.a = opacity;
......@@ -1618,15 +1616,11 @@ void
gimp_channel_push_undo (GimpChannel *channel,
const gchar *undo_desc)
{
GimpImage *gimage;
g_return_if_fail (GIMP_IS_CHANNEL (channel));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
gimage = gimp_item_get_image (GIMP_ITEM (channel));
g_return_if_fail (GIMP_IS_IMAGE (gimage));
gimp_image_undo_push_mask (gimage, undo_desc, channel);
gimp_image_undo_push_mask (gimp_item_get_image (GIMP_ITEM (channel)),
undo_desc, channel);
gimp_drawable_invalidate_boundary (GIMP_DRAWABLE (channel));
}
......@@ -1721,6 +1715,9 @@ gimp_channel_feather (GimpChannel *channel,
{
g_return_if_fail (GIMP_IS_CHANNEL (channel));
if (! gimp_item_is_attached (GIMP_ITEM (channel)))
push_undo = FALSE;
GIMP_CHANNEL_GET_CLASS (channel)->feather (channel, radius_x, radius_y,
push_undo);
}
......@@ -1731,6 +1728,9 @@ gimp_channel_sharpen (GimpChannel *channel,
{
g_return_if_fail (GIMP_IS_CHANNEL (channel));
if (! gimp_item_is_attached (GIMP_ITEM (channel)))
push_undo = FALSE;
GIMP_CHANNEL_GET_CLASS (channel)->sharpen (channel, push_undo);
}
......@@ -1741,6 +1741,9 @@ gimp_channel_clear (GimpChannel *channel,
{
g_return_if_fail (GIMP_IS_CHANNEL (channel));
if (! gimp_item_is_attached (GIMP_ITEM (channel)))
push_undo = FALSE;
GIMP_CHANNEL_GET_CLASS (channel)->clear (channel, undo_desc, push_undo);
}
......@@ -1750,6 +1753,9 @@ gimp_channel_all (GimpChannel *channel,
{
g_return_if_fail (GIMP_IS_CHANNEL (channel));
if (! gimp_item_is_attached (GIMP_ITEM (channel)))
push_undo = FALSE;
GIMP_CHANNEL_GET_CLASS (channel)->all (channel, push_undo);
}
......@@ -1759,6 +1765,9 @@ gimp_channel_invert (GimpChannel *channel,
{
g_return_if_fail (GIMP_IS_CHANNEL (channel));
if (! gimp_item_is_attached (GIMP_ITEM (channel)))
push_undo = FALSE;
GIMP_CHANNEL_GET_CLASS (channel)->invert (channel, push_undo);
}
......@@ -1770,6 +1779,9 @@ gimp_channel_border (GimpChannel *channel,
{
g_return_if_fail (GIMP_IS_CHANNEL (channel));
if (! gimp_item_is_attached (GIMP_ITEM (channel)))
push_undo = FALSE;
GIMP_CHANNEL_GET_CLASS (channel)->border (channel, radius_x, radius_y,
push_undo);
}
......@@ -1782,6 +1794,9 @@ gimp_channel_grow (GimpChannel *channel,
{
g_return_if_fail (GIMP_IS_CHANNEL (channel));
if (! gimp_item_is_attached (GIMP_ITEM (channel)))
push_undo = FALSE;
GIMP_CHANNEL_GET_CLASS (channel)->grow (channel, radius_x, radius_y,
push_undo);
}
......@@ -1795,6 +1810,9 @@ gimp_channel_shrink (GimpChannel *channel,
{
g_return_if_fail (GIMP_IS_CHANNEL (channel));
if (! gimp_item_is_attached (GIMP_ITEM (channel)))
push_undo = FALSE;
GIMP_CHANNEL_GET_CLASS (channel)->shrink (channel, radius_x, radius_y,
edge_lock, push_undo);
}
......@@ -45,10 +45,11 @@ gimp_drawable_desaturate (GimpDrawable *drawable)
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_drawable_is_rgb (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
has_alpha = gimp_drawable_has_alpha (drawable);
if (!gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
return;
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
......
......@@ -51,6 +51,7 @@ gimp_drawable_equalize (GimpDrawable *drawable,
GimpImage *gimage;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
bytes = gimp_drawable_bytes (drawable);
......
......@@ -41,6 +41,7 @@ gimp_drawable_calculate_histogram (GimpDrawable *drawable,
gboolean have_mask;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
g_return_if_fail (histogram != NULL);
have_mask = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
......
......@@ -40,6 +40,9 @@ gimp_drawable_invert (GimpDrawable *drawable)
gint x, y, width, height;
GimpLut *lut;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
return;
......
......@@ -58,6 +58,8 @@ gimp_drawable_levels (GimpDrawable *drawable,
/* parameter checking */
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (! gimp_drawable_is_indexed (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
g_return_if_fail (channel >= GIMP_HISTOGRAM_VALUE &&
channel <= GIMP_HISTOGRAM_ALPHA);
g_return_if_fail (low_input >= 0 && low_input <= 255);
......@@ -66,8 +68,6 @@ gimp_drawable_levels (GimpDrawable *drawable,
g_return_if_fail (low_output >= 0 && low_output <= 255);
g_return_if_fail (high_output >= 0 && high_output <= 255);
g_return_if_fail (!gimp_drawable_is_indexed (drawable));
if (channel == GIMP_HISTOGRAM_ALPHA)
g_return_if_fail (gimp_drawable_has_alpha (drawable));
......@@ -75,7 +75,7 @@ gimp_drawable_levels (GimpDrawable *drawable,
g_return_if_fail (channel == GIMP_HISTOGRAM_VALUE ||
channel == GIMP_HISTOGRAM_ALPHA);
if (!gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
return;
/* FIXME: hack */
......@@ -115,8 +115,8 @@ gimp_drawable_levels (GimpDrawable *drawable,
void
gimp_drawable_levels_stretch (GimpDrawable *drawable,
GimpContext *context)
gimp_drawable_levels_stretch (GimpDrawable *drawable,
GimpContext *context)
{
gint x, y, width, height;
PixelRegion srcPR, destPR;
......@@ -124,14 +124,12 @@ gimp_drawable_levels_stretch (GimpDrawable *drawable,
GimpLut *lut;
GimpHistogram *hist;
/* parameter checking */
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (! gimp_drawable_is_indexed (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
g_return_if_fail (GIMP_IS_CONTEXT (context));
if (gimp_drawable_is_indexed (drawable))
return;
if (!gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
return;
/* Build the histogram */
......
......@@ -312,6 +312,7 @@ gimp_drawable_offset (GimpDrawable *drawable,
}
}
gimp_drawable_set_tiles (drawable, TRUE, _("Offset Drawable"), new_tiles);
gimp_drawable_set_tiles (drawable, gimp_item_is_attached (item),
_("Offset Drawable"), new_tiles);
tile_manager_unref (new_tiles);
}
......@@ -76,6 +76,7 @@ gimp_drawable_stroke_boundary (GimpDrawable *drawable,
gint i;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
g_return_if_fail (GIMP_IS_STROKE_OPTIONS (options));
if (n_bound_segs == 0)
......@@ -148,6 +149,7 @@ gimp_drawable_stroke_vectors (GimpDrawable *drawable,
gint num_coords = 0;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
g_return_if_fail (GIMP_IS_STROKE_OPTIONS (options));
g_return_if_fail (GIMP_IS_VECTORS (vectors));
......
......@@ -145,6 +145,7 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
guchar bg_color[MAX_CHANNELS];
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (orig_tiles != NULL, NULL);
g_return_val_if_fail (matrix != NULL, NULL);
......@@ -152,8 +153,6 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
m = *matrix;
inv = *matrix;
......@@ -479,13 +478,12 @@ gimp_drawable_transform_tiles_flip (GimpDrawable *drawable,
gint i;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (orig_tiles != NULL, NULL);
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
orig_width = tile_manager_width (orig_tiles);
orig_height = tile_manager_height (orig_tiles);
orig_bpp = tile_manager_bpp (orig_tiles);
......@@ -642,13 +640,12 @@ gimp_drawable_transform_tiles_rotate (GimpDrawable *drawable,
gint i, j, k;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (orig_tiles != NULL, NULL);
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
orig_width = tile_manager_width (orig_tiles);
orig_height = tile_manager_height (orig_tiles);
orig_bpp = tile_manager_bpp (orig_tiles);
......@@ -858,8 +855,8 @@ gimp_drawable_transform_affine (GimpDrawable *drawable,
gboolean success = FALSE;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
g_return_val_if_fail (matrix != NULL, FALSE);
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), FALSE);
......@@ -922,8 +919,8 @@ gimp_drawable_transform_flip (GimpDrawable *drawable,
gboolean success = FALSE;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
......@@ -1003,8 +1000,8 @@ gimp_drawable_transform_rotate (GimpDrawable *drawable,
gboolean success = FALSE;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
......@@ -1068,13 +1065,12 @@ gimp_drawable_transform_cut (GimpDrawable *drawable,
TileManager *tiles;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (new_layer != NULL, NULL);
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
/* extract the selected mask if there is a selection */
if (! gimp_channel_is_empty (gimp_image_get_mask (gimage)))
{
......
......@@ -608,15 +608,11 @@ gimp_drawable_get_color_at (GimpPickable *pickable,
gint y)
{
GimpDrawable *drawable = GIMP_DRAWABLE (pickable);
GimpImage *gimage;
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
Tile *tile;
guchar *src;
guchar *dest;
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
/* do not make this a g_return_if_fail() */
if (x < 0 || x >= GIMP_ITEM (drawable)->width ||
y < 0 || y >= GIMP_ITEM (drawable)->height)
......@@ -892,6 +888,7 @@ gimp_drawable_apply_region (GimpDrawable *drawable,
gint y)
{
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
g_return_if_fail (src2PR != NULL);
GIMP_DRAWABLE_GET_CLASS (drawable)->apply_region (drawable, src2PR,
......@@ -912,6 +909,7 @@ gimp_drawable_replace_region (GimpDrawable *drawable,
gint y)
{
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
g_return_if_fail (src2PR != NULL);
g_return_if_fail (maskPR != NULL);
......@@ -932,6 +930,9 @@ gimp_drawable_set_tiles (GimpDrawable *drawable,
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (tiles != NULL);
if (! gimp_item_is_attached (GIMP_ITEM (drawable)))
push_undo = FALSE;
gimp_item_offsets (GIMP_ITEM (drawable), &offset_x, &offset_y);
gimp_drawable_set_tiles_full (drawable, push_undo, undo_desc, tiles,
......@@ -955,10 +956,12 @@ gimp_drawable_set_tiles_full (GimpDrawable *drawable,
g_return_if_fail (tiles != NULL);
g_return_if_fail (tile_manager_bpp (tiles) == GIMP_IMAGE_TYPE_BYTES (type));
item = GIMP_ITEM (drawable);
item = GIMP_ITEM (drawable);
gimage = gimp_item_get_image (item);
if (! gimp_item_is_attached (GIMP_ITEM (drawable)))
push_undo = FALSE;
if (item->width != tile_manager_width (tiles) ||
item->height != tile_manager_height (tiles) ||
item->offset_x != offset_x ||
......@@ -1016,6 +1019,7 @@ gimp_drawable_push_undo (GimpDrawable *drawable,
item = GIMP_ITEM (drawable);
g_return_if_fail (gimp_item_is_attached (item));
g_return_if_fail (sparse == FALSE ||
tile_manager_width (tiles) == gimp_item_width (item));
g_return_if_fail (sparse == FALSE ||
......@@ -1045,17 +1049,16 @@ gimp_drawable_push_undo (GimpDrawable *drawable,
TileManager *
gimp_drawable_shadow (GimpDrawable *drawable)
{
GimpItem *item;
GimpImage *gimage;
GimpItem *item;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
item = GIMP_ITEM (drawable);
gimage = gimp_item_get_image (item);
item = GIMP_ITEM (drawable);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (gimp_item_is_attached (item), NULL);
return gimp_image_shadow (gimage, item->width, item->height,
return gimp_image_shadow (gimp_item_get_image (item),
item->width, item->height,
drawable->bytes);
}
......@@ -1064,14 +1067,14 @@ gimp_drawable_merge_shadow (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc)
{
GimpImage *gimage;
gint x, y, width, height;
GimpImage *gimage;
gint x, y, width, height;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (gimage->shadow != NULL);
/* A useful optimization here is to limit the update to the
......@@ -1108,8 +1111,6 @@ gimp_drawable_fill (GimpDrawable *drawable,
item = GIMP_ITEM (drawable);
gimage = gimp_item_get_image (item);
g_return_if_fail (gimage != NULL);
drawable_type = gimp_drawable_type (drawable);
pixel_region_init (&destPR, gimp_drawable_data (drawable),
......@@ -1296,8 +1297,8 @@ gimp_drawable_mask_intersect (GimpDrawable *drawable,
width, height);
}
*x = 0;
*y = 0;
*x = 0;
*y = 0;
*width = gimp_item_width (item);
*height = gimp_item_height (item);
......
......@@ -38,18 +38,15 @@ gimp_item_linked_translate (GimpItem *item,
gint offset_y,
gboolean push_undo)
{
GimpImage *gimage;
GList *linked_list;
GList *list;
GList *linked_list;
GList *list;
g_return_if_fail (GIMP_IS_ITEM (item));
g_return_if_fail (gimp_item_get_linked (item) == TRUE);
g_return_if_fail (gimp_item_is_attached (item));
gimage = gimp_item_get_image (item);
g_return_if_fail (GIMP_IS_IMAGE (gimage));
linked_list = gimp_item_linked_get_list (gimage, item, GIMP_ITEM_LINKED_ALL);
linked_list = gimp_item_linked_get_list (gimp_item_get_image (item),
item, GIMP_ITEM_LINKED_ALL);
for (list = linked_list; list; list = g_list_next (list))
gimp_item_translate (GIMP_ITEM (list->data),
......@@ -65,19 +62,16 @@ gimp_item_linked_flip (GimpItem *item,
gdouble axis,
gboolean clip_result)
{
GimpImage *gimage;
GList *linked_list;
GList *list;
GList *linked_list;
GList *list;
g_return_if_fail (GIMP_IS_ITEM (item));
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (gimp_item_get_linked (item) == TRUE);
g_return_if_fail (gimp_item_is_attached (item));
gimage = gimp_item_get_image (item);
g_return_if_fail (GIMP_IS_IMAGE (gimage));
linked_list = gimp_item_linked_get_list (gimage, item, GIMP_ITEM_LINKED_ALL);
linked_list = gimp_item_linked_get_list (gimp_item_get_image (item),
item, GIMP_ITEM_LINKED_ALL);
for (list = linked_list; list; list = g_list_next (list))
gimp_item_flip (GIMP_ITEM (list->data), context,
......@@ -94,19 +88,16 @@ gimp_item_linked_rotate (GimpItem *item,
gdouble center_y,
gboolean clip_result)
{
GimpImage *gimage;