Fix disable delete layer button when only one layer exists (fix #3649)

This commit is contained in:
Dariy Guzairov 2023-09-26 09:21:17 +10:00 committed by David Capello
parent fc29686bb2
commit ea35725c85

View File

@ -116,9 +116,20 @@ RemoveLayerCommand::RemoveLayerCommand()
bool RemoveLayerCommand::onEnabled(Context* context)
{
return context->checkFlags(ContextFlags::ActiveDocumentIsWritable |
ContextFlags::HasActiveSprite |
ContextFlags::HasActiveLayer);
if (!context->checkFlags(ContextFlags::ActiveDocumentIsWritable |
ContextFlags::HasActiveSprite |
ContextFlags::HasActiveLayer))
return false;
const ContextReader reader(context);
const Sprite* sprite(reader.sprite());
const Layer* layer = reader.layer();
return sprite && layer &&
// We can remove all layers from non-root groups
((layer->parent() != sprite->root()) ||
// Check that we are not removing the last layer in the sprite
(sprite->root()->layersCount() > 1));
}
void RemoveLayerCommand::onExecute(Context* context)