Fix crash calling PaletteSize without active sprite

This commit is contained in:
David Capello 2021-05-20 17:31:08 -03:00
parent 56ae29a9b4
commit bc824ed9e6

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2019-2021 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -30,6 +30,7 @@ public:
protected:
void onLoadParams(const Params& params) override;
bool onEnabled(Context* context) override;
void onExecute(Context* context) override;
private:
@ -47,6 +48,11 @@ void PaletteSizeCommand::onLoadParams(const Params& params)
m_size = params.get_as<int>("size");
}
bool PaletteSizeCommand::onEnabled(Context* context)
{
return context->checkFlags(ContextFlags::ActiveDocumentIsWritable);
}
void PaletteSizeCommand::onExecute(Context* context)
{
ContextReader reader(context);