diff --git a/src/app/commands/cmd_clear.cpp b/src/app/commands/cmd_clear.cpp index 437d67fd3b..30e8bf7ecc 100644 --- a/src/app/commands/cmd_clear.cpp +++ b/src/app/commands/cmd_clear.cpp @@ -78,6 +78,10 @@ void ClearCommand::onExecute(Context* context) ContextWriter writer(context); Document* document = writer.document(); bool visibleMask = document->isMaskVisible(); + + if (!writer.cel()) + return; + { UndoTransaction undoTransaction(writer.context(), "Clear"); DocumentApi api = document->getApi(); diff --git a/src/app/document_api.cpp b/src/app/document_api.cpp index 48b0b175cf..3e8cc2c361 100644 --- a/src/app/document_api.cpp +++ b/src/app/document_api.cpp @@ -1097,8 +1097,10 @@ void DocumentApi::replaceStockImage(Sprite* sprite, int imageIndex, Image* newIm // Clears the mask region in the current sprite with the specified background color. void DocumentApi::clearMask(Layer* layer, Cel* cel, color_t bgcolor) { + ASSERT(cel); ASSERT(layer == cel->layer()); - Image* image = cel->image(); + + Image* image = (cel ? cel->image(): NULL); if (!image) return;