mirror of
https://github.com/aseprite/aseprite.git
synced 2024-10-03 21:46:20 +00:00
Fix crash in "go to" commands, don't access to null layer
This commit is contained in:
parent
c4605ad513
commit
fabb58e0ea
@ -32,7 +32,22 @@
|
|||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
class GotoPreviousLayerCommand : public Command {
|
class GotoCommand : public Command {
|
||||||
|
public:
|
||||||
|
GotoCommand(const char* short_name, const char* friendly_name, CommandFlags flags)
|
||||||
|
: Command(short_name, friendly_name, flags) {
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void updateStatusBar(DocumentLocation& location) {
|
||||||
|
if (location.layer() != NULL)
|
||||||
|
StatusBar::instance()
|
||||||
|
->setStatusText(1000, "Layer `%s' selected",
|
||||||
|
location.layer()->getName().c_str());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class GotoPreviousLayerCommand : public GotoCommand {
|
||||||
public:
|
public:
|
||||||
GotoPreviousLayerCommand();
|
GotoPreviousLayerCommand();
|
||||||
Command* clone() { return new GotoPreviousLayerCommand(*this); }
|
Command* clone() { return new GotoPreviousLayerCommand(*this); }
|
||||||
@ -43,7 +58,7 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
GotoPreviousLayerCommand::GotoPreviousLayerCommand()
|
GotoPreviousLayerCommand::GotoPreviousLayerCommand()
|
||||||
: Command("GotoPreviousLayer",
|
: GotoCommand("GotoPreviousLayer",
|
||||||
"Goto Previous Layer",
|
"Goto Previous Layer",
|
||||||
CmdUIOnlyFlag)
|
CmdUIOnlyFlag)
|
||||||
{
|
{
|
||||||
@ -71,12 +86,10 @@ void GotoPreviousLayerCommand::onExecute(Context* context)
|
|||||||
current_editor->setLayer(location.layer());
|
current_editor->setLayer(location.layer());
|
||||||
current_editor->flashCurrentLayer();
|
current_editor->flashCurrentLayer();
|
||||||
|
|
||||||
StatusBar::instance()
|
updateStatusBar(location);
|
||||||
->setStatusText(1000, "Layer `%s' selected",
|
|
||||||
location.layer()->getName().c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class GotoNextLayerCommand : public Command {
|
class GotoNextLayerCommand : public GotoCommand {
|
||||||
public:
|
public:
|
||||||
GotoNextLayerCommand();
|
GotoNextLayerCommand();
|
||||||
Command* clone() { return new GotoNextLayerCommand(*this); }
|
Command* clone() { return new GotoNextLayerCommand(*this); }
|
||||||
@ -87,7 +100,7 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
GotoNextLayerCommand::GotoNextLayerCommand()
|
GotoNextLayerCommand::GotoNextLayerCommand()
|
||||||
: Command("GotoNextLayer",
|
: GotoCommand("GotoNextLayer",
|
||||||
"Goto Next Layer",
|
"Goto Next Layer",
|
||||||
CmdUIOnlyFlag)
|
CmdUIOnlyFlag)
|
||||||
{
|
{
|
||||||
@ -115,9 +128,7 @@ void GotoNextLayerCommand::onExecute(Context* context)
|
|||||||
current_editor->setLayer(location.layer());
|
current_editor->setLayer(location.layer());
|
||||||
current_editor->flashCurrentLayer();
|
current_editor->flashCurrentLayer();
|
||||||
|
|
||||||
StatusBar::instance()
|
updateStatusBar(location);
|
||||||
->setStatusText(1000, "Layer `%s' selected",
|
|
||||||
location.layer()->getName().c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Command* CommandFactory::createGotoPreviousLayerCommand()
|
Command* CommandFactory::createGotoPreviousLayerCommand()
|
||||||
|
Loading…
Reference in New Issue
Block a user