mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-31 00:32:48 +00:00
Fixed bug in LayerImage::destroy_all_cels() using cel_is_link() in deleted cels.
Removed cel_is_link() function because link cels do not exist anymore.
This commit is contained in:
parent
8ff997d2d2
commit
b676b74166
@ -830,8 +830,7 @@ static Cel *ase_file_read_cel_chunk(FILE *f, Sprite *sprite, int frame, int imgt
|
||||
static void ase_file_write_cel_chunk(FILE *f, Cel *cel, LayerImage *layer, Sprite *sprite)
|
||||
{
|
||||
int layer_index = sprite_layer2index(sprite, layer);
|
||||
Cel *link = cel_is_link(cel, layer);
|
||||
int cel_type = link ? ASE_FILE_LINK_CEL: ASE_FILE_RAW_CEL;
|
||||
int cel_type = ASE_FILE_RAW_CEL;
|
||||
|
||||
ase_file_write_start_chunk(f, ASE_FILE_CHUNK_CEL);
|
||||
|
||||
@ -896,7 +895,8 @@ static void ase_file_write_cel_chunk(FILE *f, Cel *cel, LayerImage *layer, Sprit
|
||||
|
||||
case ASE_FILE_LINK_CEL:
|
||||
/* linked cel to another frame */
|
||||
fputw(link->frame, f);
|
||||
//fputw(link->frame, f);
|
||||
fputw(0, f);
|
||||
break;
|
||||
|
||||
case ASE_FILE_RLE_COMPRESSED_CEL:
|
||||
|
@ -68,20 +68,6 @@ void cel_free(Cel* cel)
|
||||
delete cel;
|
||||
}
|
||||
|
||||
Cel* cel_is_link(Cel* cel, LayerImage* layer)
|
||||
{
|
||||
Cel* link;
|
||||
int frame;
|
||||
|
||||
for (frame=0; frame<cel->frame; frame++) {
|
||||
link = layer->get_cel(frame);
|
||||
if (link && link->image == cel->image)
|
||||
return link;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @warning You have to remove the cel from the layer before to change
|
||||
* the frame position.
|
||||
|
@ -40,8 +40,6 @@ Cel* cel_new(int frame, int image);
|
||||
Cel* cel_new_copy(const Cel* cel);
|
||||
void cel_free(Cel* cel);
|
||||
|
||||
Cel* cel_is_link(Cel* cel, LayerImage* layer);
|
||||
|
||||
void cel_set_frame(Cel* cel, int frame);
|
||||
void cel_set_image(Cel* cel, int image);
|
||||
void cel_set_position(Cel* cel, int x, int y);
|
||||
|
@ -160,18 +160,15 @@ void LayerImage::destroy_all_cels()
|
||||
|
||||
for (; it != end; ++it) {
|
||||
Cel* cel = *it;
|
||||
Image* image = getSprite()->stock->image[cel->image];
|
||||
|
||||
if (!cel_is_link(cel, this)) {
|
||||
Image* image = getSprite()->stock->image[cel->image];
|
||||
|
||||
assert(image != NULL);
|
||||
|
||||
stock_remove_image(getSprite()->stock, image);
|
||||
image_free(image);
|
||||
}
|
||||
assert(image != NULL);
|
||||
|
||||
stock_remove_image(getSprite()->stock, image);
|
||||
image_free(image);
|
||||
cel_free(cel);
|
||||
}
|
||||
m_cels.clear();
|
||||
}
|
||||
|
||||
void LayerImage::set_blend_mode(int blend_mode)
|
||||
@ -306,6 +303,7 @@ void LayerFolder::destroy_all_layers()
|
||||
Layer* layer = *it;
|
||||
delete layer;
|
||||
}
|
||||
m_layers.clear();
|
||||
}
|
||||
|
||||
void LayerFolder::get_cels(CelList& cels)
|
||||
|
@ -2065,16 +2065,11 @@ static ase_uint8* write_raw_layer(ase_uint8* raw_data, Layer* layer)
|
||||
Cel* cel = *it;
|
||||
raw_data = write_raw_cel(raw_data, cel);
|
||||
|
||||
if (cel_is_link(cel, static_cast<LayerImage*>(layer))) {
|
||||
write_raw_uint8(0);
|
||||
}
|
||||
else {
|
||||
Image* image = layer->getSprite()->stock->image[cel->image];
|
||||
assert(image != NULL);
|
||||
Image* image = layer->getSprite()->stock->image[cel->image];
|
||||
assert(image != NULL);
|
||||
|
||||
write_raw_uint8(1);
|
||||
raw_data = write_raw_image(raw_data, image);
|
||||
}
|
||||
write_raw_uint8(1);
|
||||
raw_data = write_raw_image(raw_data, image);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -2113,10 +2108,9 @@ static int get_raw_layer_size(Layer* layer)
|
||||
Cel* cel = *it;
|
||||
size += get_raw_cel_size(cel);
|
||||
size++; // has image?
|
||||
if (!cel_is_link(cel, static_cast<LayerImage*>(layer))) {
|
||||
Image* image = layer->getSprite()->stock->image[cel->image];
|
||||
size += get_raw_image_size(image);
|
||||
}
|
||||
|
||||
Image* image = layer->getSprite()->stock->image[cel->image];
|
||||
size += get_raw_image_size(image);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user