mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-29 03:32:48 +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 {
|
||||
|
||||
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:
|
||||
GotoPreviousLayerCommand();
|
||||
Command* clone() { return new GotoPreviousLayerCommand(*this); }
|
||||
@ -43,9 +58,9 @@ protected:
|
||||
};
|
||||
|
||||
GotoPreviousLayerCommand::GotoPreviousLayerCommand()
|
||||
: Command("GotoPreviousLayer",
|
||||
"Goto Previous Layer",
|
||||
CmdUIOnlyFlag)
|
||||
: GotoCommand("GotoPreviousLayer",
|
||||
"Goto Previous Layer",
|
||||
CmdUIOnlyFlag)
|
||||
{
|
||||
}
|
||||
|
||||
@ -71,12 +86,10 @@ void GotoPreviousLayerCommand::onExecute(Context* context)
|
||||
current_editor->setLayer(location.layer());
|
||||
current_editor->flashCurrentLayer();
|
||||
|
||||
StatusBar::instance()
|
||||
->setStatusText(1000, "Layer `%s' selected",
|
||||
location.layer()->getName().c_str());
|
||||
updateStatusBar(location);
|
||||
}
|
||||
|
||||
class GotoNextLayerCommand : public Command {
|
||||
class GotoNextLayerCommand : public GotoCommand {
|
||||
public:
|
||||
GotoNextLayerCommand();
|
||||
Command* clone() { return new GotoNextLayerCommand(*this); }
|
||||
@ -87,9 +100,9 @@ protected:
|
||||
};
|
||||
|
||||
GotoNextLayerCommand::GotoNextLayerCommand()
|
||||
: Command("GotoNextLayer",
|
||||
"Goto Next Layer",
|
||||
CmdUIOnlyFlag)
|
||||
: GotoCommand("GotoNextLayer",
|
||||
"Goto Next Layer",
|
||||
CmdUIOnlyFlag)
|
||||
{
|
||||
}
|
||||
|
||||
@ -115,9 +128,7 @@ void GotoNextLayerCommand::onExecute(Context* context)
|
||||
current_editor->setLayer(location.layer());
|
||||
current_editor->flashCurrentLayer();
|
||||
|
||||
StatusBar::instance()
|
||||
->setStatusText(1000, "Layer `%s' selected",
|
||||
location.layer()->getName().c_str());
|
||||
updateStatusBar(location);
|
||||
}
|
||||
|
||||
Command* CommandFactory::createGotoPreviousLayerCommand()
|
||||
|
Loading…
x
Reference in New Issue
Block a user