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

ref new tiles before unrefing the old ones.

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

	* app/core/gimpdrawable.c (gimp_drawable_set_tiles): ref new
	tiles before unrefing the old ones.

	* app/core/gimpimage-undo-push.c: keep undo memsize exact by
	adjusting undo->size when the stored data changes.

	* app/core/gimpchannel.[ch] (gimp_channel_new_from_alpha)
	* app/core/gimpchannel-select.[ch] (gimp_channel_select_alpha):
	replaced "layer" parameter by "drawable".

	* app/gui/layers-commands.c
	* tools/pdbgen/pdb/selection.pdb: changed accordingly.

	* app/pdb/selection_cmds.c: regenerated.

	* app/core/gimpchannel.c
	* app/core/gimplayer.c
	* app/core/gimplayermask.[ch]
	* app/core/gimpselection.c: remdom cleanup & code review.
parent 05410dc0
2004-03-16 Michael Natterer <mitch@gimp.org>
* app/core/gimpdrawable.c (gimp_drawable_set_tiles): ref new
tiles before unrefing the old ones.
* app/core/gimpimage-undo-push.c: keep undo memsize exact by
adjusting undo->size when the stored data changes.
* app/core/gimpchannel.[ch] (gimp_channel_new_from_alpha)
* app/core/gimpchannel-select.[ch] (gimp_channel_select_alpha):
replaced "layer" parameter by "drawable".
* app/gui/layers-commands.c
* tools/pdbgen/pdb/selection.pdb: changed accordingly.
* app/pdb/selection_cmds.c: regenerated.
* app/core/gimpchannel.c
* app/core/gimplayer.c
* app/core/gimplayermask.[ch]
* app/core/gimpselection.c: remdom cleanup & code review.
2004-03-16 Michael Natterer <mitch@gimp.org>
* app/core/gimplist.c (gimp_list_dispose): removed this function.
......@@ -491,7 +491,8 @@ layers_alpha_to_selection_cmd_callback (GtkWidget *widget,
op = (GimpChannelOps) action;
gimp_channel_select_alpha (gimp_image_get_mask (gimage), active_layer,
gimp_channel_select_alpha (gimp_image_get_mask (gimage),
GIMP_DRAWABLE (active_layer),
op, FALSE, 0.0, 0.0);
gimp_image_flush (gimage);
}
......
......@@ -28,7 +28,6 @@
#include "gimpchannel-select.h"
#include "gimpchannel-combine.h"
#include "gimpimage-contiguous-region.h"
#include "gimplayer.h"
#include "gimpscanconvert.h"
#include "vectors/gimpstroke.h"
......@@ -328,7 +327,7 @@ gimp_channel_select_channel (GimpChannel *channel,
void
gimp_channel_select_alpha (GimpChannel *channel,
GimpLayer *layer,
GimpDrawable *drawable,
GimpChannelOps op,
gboolean feather,
gdouble feather_radius_x,
......@@ -339,18 +338,18 @@ gimp_channel_select_alpha (GimpChannel *channel,
gint off_x, off_y;
g_return_if_fail (GIMP_IS_CHANNEL (channel));
g_return_if_fail (GIMP_IS_LAYER (layer));
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
item = GIMP_ITEM (channel);
if (gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
if (gimp_drawable_has_alpha (drawable))
{
GimpRGB color;
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
add_on = gimp_channel_new_from_alpha (gimp_item_get_image (item),
layer, NULL, &color);
drawable, NULL, &color);
}
else
{
......@@ -358,12 +357,12 @@ gimp_channel_select_alpha (GimpChannel *channel,
* so simply select the whole layer's extents. --mitch
*/
add_on = gimp_channel_new_mask (gimp_item_get_image (item),
gimp_item_width (GIMP_ITEM (layer)),
gimp_item_height (GIMP_ITEM (layer)));
gimp_item_width (GIMP_ITEM (drawable)),
gimp_item_height (GIMP_ITEM (drawable)));
gimp_channel_all (add_on, FALSE);
}
gimp_item_offsets (GIMP_ITEM (layer), &off_x, &off_y);
gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
gimp_channel_select_channel (channel, _("Alpha to Selection"), add_on,
off_x, off_y,
......
......@@ -86,7 +86,7 @@ void gimp_channel_select_channel (GimpChannel *channel,
gdouble feather_radius_x,
gdouble feather_radius_y);
void gimp_channel_select_alpha (GimpChannel *channel,
GimpLayer *layer,
GimpDrawable *drawable,
GimpChannelOps op,
gboolean feather,
gdouble feather_radius_x,
......
......@@ -49,7 +49,6 @@
#include "gimpchannel.h"
#include "gimpcontext.h"
#include "gimpdrawable-stroke.h"
#include "gimplayer.h"
#include "gimppaintinfo.h"
#include "gimpstrokeoptions.h"
......@@ -227,17 +226,11 @@ gimp_channel_get_type (void)
static void
gimp_channel_class_init (GimpChannelClass *klass)
{
GObjectClass *object_class;
GimpObjectClass *gimp_object_class;
GimpViewableClass *viewable_class;
GimpItemClass *item_class;
GimpDrawableClass *drawable_class;
object_class = G_OBJECT_CLASS (klass);
gimp_object_class = GIMP_OBJECT_CLASS (klass);
viewable_class = GIMP_VIEWABLE_CLASS (klass);
item_class = GIMP_ITEM_CLASS (klass);
drawable_class = GIMP_DRAWABLE_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
GimpItemClass *item_class = GIMP_ITEM_CLASS (klass);
GimpDrawableClass *drawable_class = GIMP_DRAWABLE_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
......@@ -375,9 +368,7 @@ gimp_channel_duplicate (GimpItem *item,
channel = GIMP_CHANNEL (item);
new_channel = GIMP_CHANNEL (new_item);
/* set the channel color and opacity */
new_channel->color = channel->color;
new_channel->show_masked = channel->show_masked;
/* selection mask variables */
......@@ -397,21 +388,17 @@ gimp_channel_translate (GimpItem *item,
gint off_y,
gboolean push_undo)
{
GimpChannel *channel;
GimpChannel *channel = GIMP_CHANNEL (item);
GimpChannel *tmp_mask = NULL;
gint width, height;
PixelRegion srcPR, destPR;
guchar empty = TRANSPARENT_OPACITY;
gint x1, y1, x2, y2;
channel = GIMP_CHANNEL (item);
gimp_channel_bounds (channel, &x1, &y1, &x2, &y2);
/* update the old area */
gimp_drawable_update (GIMP_DRAWABLE (item),
x1, y1,
x2 - x1, y2 - y1);
gimp_drawable_update (GIMP_DRAWABLE (item), x1, y1, x2 - x1, y2 - y1);
if (push_undo)
gimp_channel_push_undo (channel,
......@@ -532,11 +519,7 @@ gimp_channel_flip (GimpItem *item,
gdouble axis,
gboolean clip_result)
{
GimpChannel *channel;
GimpImage *gimage;
channel = GIMP_CHANNEL (item);
gimage = gimp_item_get_image (item);
GimpImage *gimage = gimp_item_get_image (item);
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TRANSFORM,
_("Flip Channel"));
......@@ -547,9 +530,6 @@ gimp_channel_flip (GimpItem *item,
GIMP_ITEM_CLASS (parent_class)->flip (item, flip_type, axis, clip_result);
gimp_image_undo_group_end (gimage);
/* bounds are now unknown */
channel->bounds_known = FALSE;
}
static void
......@@ -559,11 +539,7 @@ gimp_channel_rotate (GimpItem *item,
gdouble center_y,
gboolean clip_result)
{
GimpChannel *channel;
GimpImage *gimage;
channel = GIMP_CHANNEL (item);
gimage = gimp_item_get_image (item);
GimpImage *gimage = gimp_item_get_image (item);
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TRANSFORM,
_("Rotate Channel"));
......@@ -575,9 +551,6 @@ gimp_channel_rotate (GimpItem *item,
clip_result);
gimp_image_undo_group_end (gimage);
/* bounds are now unknown */
channel->bounds_known = FALSE;
}
static void
......@@ -591,11 +564,7 @@ gimp_channel_transform (GimpItem *item,
GimpProgressFunc progress_callback,
gpointer progress_data)
{
GimpChannel *channel;
GimpImage *gimage;
channel = GIMP_CHANNEL (item);
gimage = gimp_item_get_image (item);
GimpImage *gimage = gimp_item_get_image (item);
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TRANSFORM,
_("Transform Channel"));
......@@ -610,9 +579,6 @@ gimp_channel_transform (GimpItem *item,
progress_callback, progress_data);
gimp_image_undo_group_end (gimage);
/* bounds are now unknown */
channel->bounds_known = FALSE;
}
static gboolean
......@@ -693,9 +659,7 @@ gimp_channel_stroke (GimpItem *item,
static void
gimp_channel_invalidate_boundary (GimpDrawable *drawable)
{
GimpChannel *channel = GIMP_CHANNEL (drawable);
channel->boundary_known = FALSE;
GIMP_CHANNEL (drawable)->boundary_known = FALSE;
}
static void
......@@ -809,7 +773,8 @@ gimp_channel_real_boundary (GimpChannel *channel,
if (gimp_channel_bounds (channel, &x3, &y3, &x4, &y4))
{
pixel_region_init (&bPR, GIMP_DRAWABLE (channel)->tiles,
x3, y3, (x4 - x3), (y4 - y3), FALSE);
x3, y3, x4 - x3, y4 - y3, FALSE);
channel->segs_out = find_mask_boundary (&bPR, &channel->num_segs_out,
IgnoreBounds,
x1, y1,
......@@ -826,6 +791,7 @@ gimp_channel_real_boundary (GimpChannel *channel,
0, 0,
GIMP_ITEM (channel)->width,
GIMP_ITEM (channel)->height, FALSE);
channel->segs_in = find_mask_boundary (&bPR, &channel->num_segs_in,
WithinBounds,
x1, y1,
......@@ -1452,9 +1418,7 @@ gimp_channel_new (GimpImage *gimage,
0, 0, width, height,
GIMP_GRAY_IMAGE, name);
/* set the channel color and opacity */
channel->color = *color;
channel->show_masked = TRUE;
/* selection mask variables */
......@@ -1466,7 +1430,7 @@ gimp_channel_new (GimpImage *gimage,
GimpChannel *
gimp_channel_new_from_alpha (GimpImage *gimage,
GimpLayer *layer,
GimpDrawable *drawable,
const gchar *name,
const GimpRGB *color)
{
......@@ -1476,18 +1440,18 @@ gimp_channel_new_from_alpha (GimpImage *gimage,
PixelRegion srcPR, destPR;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
g_return_val_if_fail (gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)), NULL);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (gimp_drawable_has_alpha (drawable), NULL);
g_return_val_if_fail (color != NULL, NULL);
width = gimp_item_width (GIMP_ITEM (layer));
height = gimp_item_height (GIMP_ITEM (layer));
width = gimp_item_width (GIMP_ITEM (drawable));
height = gimp_item_height (GIMP_ITEM (drawable));
channel = gimp_channel_new (gimage, width, height, name, color);
gimp_channel_clear (channel, NULL, FALSE);
pixel_region_init (&srcPR, gimp_drawable_data (GIMP_DRAWABLE (layer)),
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
0, 0, width, height, FALSE);
pixel_region_init (&destPR, gimp_drawable_data (GIMP_DRAWABLE (channel)),
0, 0, width, height, TRUE);
......@@ -1528,7 +1492,7 @@ gimp_channel_new_from_component (GimpImage *gimage,
pixel_region_init (&src, projection,
0, 0, width, height, FALSE);
pixel_region_init (&dest, GIMP_DRAWABLE (channel)->tiles,
pixel_region_init (&dest, gimp_drawable_data (GIMP_DRAWABLE (channel)),
0, 0, width, height, TRUE);
copy_component (&src, &dest, pixel);
......@@ -1668,11 +1632,9 @@ gimp_channel_new_mask (GimpImage *gimage,
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
/* Create the new channel */
new_channel = gimp_channel_new (gimage, width, height,
_("Selection Mask"), &black);
/* Set the validate procedure */
tile_manager_set_validate_proc (GIMP_DRAWABLE (new_channel)->tiles,
gimp_channel_validate);
......
......@@ -40,7 +40,7 @@ struct _GimpChannel
{
GimpDrawable parent_instance;
GimpRGB color; /* Also stored the opacity */
GimpRGB color; /* Also stores the opacity */
gboolean show_masked; /* Show masked areas--as */
/* opposed to selected areas */
......@@ -129,7 +129,7 @@ GimpChannel * gimp_channel_new (GimpImage *gimage,
const GimpRGB *color);
GimpChannel * gimp_channel_new_from_alpha (GimpImage *gimage,
GimpLayer *layer,
GimpDrawable *drawable,
const gchar *name,
const GimpRGB *color);
GimpChannel * gimp_channel_new_from_component (GimpImage *gimage,
......
......@@ -590,10 +590,13 @@ gimp_drawable_real_set_tiles (GimpDrawable *drawable,
gimp_image_undo_push_drawable_mod (gimp_item_get_image (item), undo_desc,
drawable);
/* ref new before unrefing old, they might be the same */
tile_manager_ref (tiles);
if (drawable->tiles)
tile_manager_unref (drawable->tiles);
drawable->tiles = tile_manager_ref (tiles);
drawable->tiles = tiles;
drawable->type = type;
drawable->bytes = tile_manager_bpp (tiles);
drawable->has_alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (type);
......
......@@ -640,6 +640,8 @@ undo_pop_drawable (GimpUndo *undo,
{
DrawableUndo *drawable_undo = undo->data;
undo->size -= tile_manager_get_memsize (drawable_undo->tiles);
gimp_drawable_swap_pixels (GIMP_DRAWABLE (GIMP_ITEM_UNDO (undo)->item),
drawable_undo->tiles,
drawable_undo->sparse,
......@@ -648,6 +650,8 @@ undo_pop_drawable (GimpUndo *undo,
drawable_undo->width,
drawable_undo->height);
undo->size += tile_manager_get_memsize (drawable_undo->tiles);
return TRUE;
}
......@@ -683,9 +687,9 @@ static void undo_free_drawable_mod (GimpUndo *undo,
GimpUndoMode undo_mode);
gboolean
gimp_image_undo_push_drawable_mod (GimpImage *gimage,
const gchar *undo_desc,
GimpDrawable *drawable)
gimp_image_undo_push_drawable_mod (GimpImage *gimage,
const gchar *undo_desc,
GimpDrawable *drawable)
{
GimpUndo *new;
gint64 size;
......@@ -726,6 +730,8 @@ undo_pop_drawable_mod (GimpUndo *undo,
GimpImageType drawable_type;
gint offset_x, offset_y;
undo->size -= tile_manager_get_memsize (drawable_undo->tiles);
tiles = drawable_undo->tiles;
drawable_type = drawable_undo->type;
offset_x = drawable_undo->offset_x;
......@@ -740,6 +746,8 @@ undo_pop_drawable_mod (GimpUndo *undo,
tiles, drawable_type, offset_x, offset_y);
tile_manager_unref (tiles);
undo->size += tile_manager_get_memsize (drawable_undo->tiles);
return TRUE;
}
......@@ -777,7 +785,7 @@ gimp_image_undo_push_mask (GimpImage *gimage,
const gchar *undo_desc,
GimpChannel *mask)
{
TileManager *undo_tiles;
TileManager *undo_tiles = NULL;
gint x1, y1, x2, y2;
GimpUndo *new;
gint64 size;
......@@ -785,26 +793,25 @@ gimp_image_undo_push_mask (GimpImage *gimage,
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (GIMP_IS_CHANNEL (mask), FALSE);
size = sizeof (MaskUndo);
if (gimp_channel_bounds (mask, &x1, &y1, &x2, &y2))
{
PixelRegion srcPR, destPR;
GimpDrawable *drawable = GIMP_DRAWABLE (mask);
PixelRegion srcPR, destPR;
undo_tiles = tile_manager_new ((x2 - x1), (y2 - y1), 1);
undo_tiles = tile_manager_new (x2 - x1, y2 - y1,
gimp_drawable_bytes (drawable));
pixel_region_init (&srcPR, GIMP_DRAWABLE (mask)->tiles,
x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
x1, y1, x2 - x1, y2 - y1, FALSE);
pixel_region_init (&destPR, undo_tiles,
0, 0, (x2 - x1), (y2 - y1), TRUE);
0, 0, x2 - x1, y2 - y1, TRUE);
copy_region (&srcPR, &destPR);
}
else
undo_tiles = NULL;
size = sizeof (MaskUndo);
if (undo_tiles)
size += tile_manager_get_memsize (undo_tiles);
size += tile_manager_get_memsize (undo_tiles);
}
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (mask),
size, sizeof (MaskUndo),
......@@ -813,11 +820,11 @@ gimp_image_undo_push_mask (GimpImage *gimage,
undo_pop_mask,
undo_free_mask)))
{
MaskUndo *mu = new->data;
MaskUndo *mask_undo = new->data;
mu->tiles = undo_tiles;
mu->x = x1;
mu->y = y1;
mask_undo->tiles = undo_tiles;
mask_undo->x = x1;
mask_undo->y = y1;
return TRUE;
}
......@@ -842,6 +849,9 @@ undo_pop_mask (GimpUndo *undo,
gint height = 0;
guchar empty = 0;
if (mu->tiles)
undo->size -= tile_manager_get_memsize (mu->tiles);
if (gimp_channel_bounds (channel, &x1, &y1, &x2, &y2))
{
new_tiles = tile_manager_new ((x2 - x1), (y2 - y1), 1);
......@@ -911,6 +921,9 @@ undo_pop_mask (GimpUndo *undo,
GIMP_ITEM (channel)->width,
GIMP_ITEM (channel)->height);
if (mu->tiles)
undo->size += tile_manager_get_memsize (mu->tiles);
return TRUE;
}
......@@ -935,7 +948,7 @@ typedef struct _ItemRenameUndo ItemRenameUndo;
struct _ItemRenameUndo
{
gchar *old_name;
gchar *name;
};
static gboolean undo_pop_item_rename (GimpUndo *undo,
......@@ -969,7 +982,7 @@ gimp_image_undo_push_item_rename (GimpImage *gimage,
{
ItemRenameUndo *iru = new->data;
iru->old_name = g_strdup (name);
iru->name = g_strdup (name);
return TRUE;
}
......@@ -986,10 +999,14 @@ undo_pop_item_rename (GimpUndo *undo,
GimpItem *item = GIMP_ITEM_UNDO (undo)->item;
gchar *tmp;
undo->size -= strlen (iru->name);
tmp = g_strdup (gimp_object_get_name (GIMP_OBJECT (item)));
gimp_object_set_name (GIMP_OBJECT (item), iru->old_name);
g_free (iru->old_name);
iru->old_name = tmp;
gimp_object_set_name (GIMP_OBJECT (item), iru->name);
g_free (iru->name);
iru->name = tmp;
undo->size += strlen (iru->name);
return TRUE;
}
......@@ -1000,7 +1017,7 @@ undo_free_item_rename (GimpUndo *undo,
{
ItemRenameUndo *iru = undo->data;
g_free (iru->old_name);
g_free (iru->name);
g_free (iru);
}
......@@ -1325,12 +1342,6 @@ undo_pop_layer (GimpUndo *undo,
{
/* remove layer */
#if 0
g_printerr ("undo_pop_layer: taking ownership, size += "
"%" G_GINT64_FORMAT "\n",
gimp_object_get_memsize (GIMP_OBJECT (layer), NULL));
#endif
undo->size += gimp_object_get_memsize (GIMP_OBJECT (layer), NULL);
/* record the current position */
......@@ -1372,12 +1383,6 @@ undo_pop_layer (GimpUndo *undo,
{
/* restore layer */
#if 0
g_printerr ("undo_pop_layer: dropping ownership, size -= "
"%" G_GINT64_FORMAT "\n",
gimp_object_get_memsize (GIMP_OBJECT (layer), NULL));
#endif
undo->size -= gimp_object_get_memsize (GIMP_OBJECT (layer), NULL);
/* record the active layer */
......@@ -1473,8 +1478,7 @@ undo_push_layer_mask (GimpImage *gimage,
size += gimp_object_get_memsize (GIMP_OBJECT (mask), NULL);
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (layer),
size,
sizeof (LayerMaskUndo),
size, sizeof (LayerMaskUndo),
type, undo_desc,
TRUE,
undo_pop_layer_mask,
......@@ -1763,8 +1767,7 @@ gimp_image_undo_push_text_layer (GimpImage *gimage,
size += gimp_object_get_memsize (GIMP_OBJECT (layer->text), NULL);
undo = gimp_image_undo_push_item (gimage, GIMP_ITEM (layer),
size,
sizeof (TextUndo),
size, sizeof (TextUndo),
GIMP_UNDO_TEXT_LAYER, undo_desc,
TRUE,
undo_pop_text_layer,
......@@ -1792,6 +1795,9 @@ undo_pop_text_layer (GimpUndo *undo,
GimpTextLayer *layer = GIMP_TEXT_LAYER (GIMP_ITEM_UNDO (undo)->item);
GimpText *text;
if (tu->text)
undo->size -= gimp_object_get_memsize (GIMP_OBJECT (tu->text), NULL);
text = (layer->text ?
gimp_config_duplicate (GIMP_CONFIG (layer->text)) : NULL);
......@@ -1802,6 +1808,9 @@ undo_pop_text_layer (GimpUndo *undo,
tu->text = text;
if (tu->text)
undo->size += gimp_object_get_memsize (GIMP_OBJECT (tu->text), NULL);
return TRUE;
}
......@@ -1888,8 +1897,7 @@ undo_push_channel (GimpImage *gimage,
size += gimp_object_get_memsize (GIMP_OBJECT (channel), NULL);
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (channel),
size,
sizeof (ChannelUndo),
size, sizeof (ChannelUndo),
type, undo_desc,
TRUE,
undo_pop_channel,
......@@ -2172,8 +2180,7 @@ undo_push_vectors (GimpImage *gimage,
size += gimp_object_get_memsize (GIMP_OBJECT (vectors), NULL);
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (vectors),
size,
sizeof (VectorsUndo),
size, sizeof (VectorsUndo),
type, undo_desc,
TRUE,
undo_pop_vectors,
......@@ -2250,7 +2257,7 @@ typedef struct _VectorsModUndo VectorsModUndo;
struct _VectorsModUndo
{
GimpVectors *undo_vectors;
GimpVectors *vectors;
};
static gboolean undo_pop_vectors_mod (GimpUndo *undo,
......@@ -2264,18 +2271,22 @@ gimp_image_undo_push_vectors_mod (GimpImage *gimage,
const gchar *undo_desc,
GimpVectors *vectors)
{
GimpUndo *new;
gint64 size;
GimpVectors *copy;
GimpUndo *new;
gint64 size;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE);
copy = GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors),
G_TYPE_FROM_INSTANCE (vectors),
FALSE));
size = (sizeof (VectorsModUndo) +
gimp_object_get_memsize (GIMP_OBJECT (vectors), NULL));
gimp_object_get_memsize (GIMP_OBJECT (copy), NULL));
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (vectors),
size,
sizeof (VectorsModUndo),
size, sizeof (VectorsModUndo),
GIMP_UNDO_VECTORS_MOD, undo_desc,
TRUE,
undo_pop_vectors_mod,
......@@ -2283,13 +2294,14 @@ gimp_image_undo_push_vectors_mod (GimpImage *gimage,
{
VectorsModUndo *vmu = new->data;
vmu->undo_vectors = GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors),
G_TYPE_FROM_INSTANCE (vectors),
FALSE));
vmu->vectors = copy;
return TRUE;
}
if (copy)
g_object_unref (copy);
return FALSE;
}
......@@ -2302,9 +2314,11 @@ undo_pop_vectors_mod (GimpUndo *undo,
GimpVectors *vectors = GIMP_VECTORS (GIMP_ITEM_UNDO (undo)->item);
GimpVectors *temp;
temp = vmu->undo_vectors;
undo->size -= gimp_object_get_memsize (GIMP_OBJECT (vmu->vectors), NULL);
vmu->undo_vectors =
temp = vmu->vectors;
vmu->vectors =
GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors),
G_TYPE_FROM_INSTANCE (vectors),
FALSE));
......@@ -2322,6 +2336,8 @@ undo_pop_vectors_mod (GimpUndo *undo,
gimp_vectors_thaw (vectors);
undo->size += gimp_object_get_memsize (GIMP_OBJECT (vmu->vectors), NULL);
return TRUE;
}
......@@ -2331,7 +2347,7 @@ undo_free_vectors_mod (GimpUndo *undo,
{
VectorsModUndo *vmu = undo->data;
g_object_unref (vmu->undo_vectors);
g_object_unref (vmu->vectors);
g_free (vmu);
}
......@@ -2843,9 +2859,7 @@ static void
undo_free_parasite (GimpUndo *undo,
GimpUndoMode undo_mode)
{
ParasiteUndo *pu;
pu = (ParasiteUndo *) undo->data;
ParasiteUndo *pu = undo->data;
if (pu->parasite)
gimp_parasite_free (pu->parasite);
......
......@@ -159,19 +159,19 @@ gimp_layer_get_type (void)
static const GTypeInfo layer_info =
{
sizeof (GimpLayerClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_layer_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpLayer),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_layer_init,
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_layer_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpLayer),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_layer_init,
};
layer_type = g_type_register_static (GIMP_TYPE_DRAWABLE,
"GimpLayer",
&layer_info, 0);
"GimpLayer",
&layer_info, 0);
}
return layer_type;
......@@ -180,17 +180,11 @@ gimp_layer_get_type (void)
static void
gimp_layer_class_init (GimpLayerClass *klass)
{
GObjectClass *object_class;
GimpObjectClass *gimp_object_class;
GimpViewableClass *viewable_class;
GimpItemClass *item_class;
GimpDrawableClass *drawable_class;