Fix Flatten Visible crash when no layers are visible

Bug founded by Jerry Pie from Steam
https://steamcommunity.com/app/431730/discussions/0/1606022547906751802/
This commit is contained in:
Gaspar Capello 2019-10-17 10:37:33 -03:00 committed by David Capello
parent 558943ebec
commit 398daf14db

View File

@ -61,10 +61,12 @@ void FlattenLayers::onExecute()
backgroundIsSel = true;
}
LayerList list = layers.toLayerList();
if (list.empty())
return; // Do nothing
// Create a temporary image.
ImageRef image(Image::create(sprite->pixelFormat(),
sprite->width(),
sprite->height()));
ImageRef image(Image::create(sprite->spec()));
LayerImage* flatLayer; // The layer onto which everything will be flattened.
color_t bgcolor; // The background color to use for flatLayer.
@ -82,7 +84,6 @@ void FlattenLayers::onExecute()
executeAndAdd(new cmd::SetLayerName(flatLayer, "Flattened"));
bgcolor = sprite->transparentColor();
LayerList list = layers.toLayerList();
if (list.front())
executeAndAdd(new cmd::MoveLayer(flatLayer,
list.front()->parent(),