mirror of
https://github.com/aseprite/aseprite.git
synced 2024-12-28 15:20:15 +00:00
Fix crash on GotoNext/PreviousFrameWithSameTagCommands when there is no tag
Some other minor changes as avoid casting int <-> frame_t because now frame_t is a typedef (some time ago it was a class and those cast were necessary). Related to #887
This commit is contained in:
parent
45e4c4656a
commit
f389a2ec23
@ -53,7 +53,7 @@ public:
|
||||
|
||||
protected:
|
||||
frame_t onGetFrame(Editor* editor) override {
|
||||
return frame_t(0);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
@ -67,11 +67,9 @@ public:
|
||||
protected:
|
||||
frame_t onGetFrame(Editor* editor) override {
|
||||
frame_t frame = editor->frame();
|
||||
frame_t last = editor->sprite()->lastFrame();
|
||||
|
||||
if (frame > frame_t(0))
|
||||
return frame-1;
|
||||
else
|
||||
return editor->sprite()->lastFrame();
|
||||
return (frame > 0 ? frame-1: last);
|
||||
}
|
||||
};
|
||||
|
||||
@ -84,10 +82,9 @@ public:
|
||||
protected:
|
||||
frame_t onGetFrame(Editor* editor) override {
|
||||
frame_t frame = editor->frame();
|
||||
if (frame < editor->sprite()->lastFrame())
|
||||
return frame+1;
|
||||
else
|
||||
return frame_t(0);
|
||||
frame_t last = editor->sprite()->lastFrame();
|
||||
|
||||
return (frame < last ? frame+1: 0);
|
||||
}
|
||||
};
|
||||
|
||||
@ -99,15 +96,12 @@ public:
|
||||
|
||||
protected:
|
||||
frame_t onGetFrame(Editor* editor) override {
|
||||
Sprite* sprite = editor->sprite();
|
||||
frame_t currentFrame = editor->frame();
|
||||
FrameTag* tag = get_animation_tag(sprite, currentFrame);
|
||||
frame_t frameToGo = currentFrame + frame_t(1);
|
||||
frame_t frame = editor->frame();
|
||||
FrameTag* tag = get_animation_tag(editor->sprite(), frame);
|
||||
frame_t first = (tag ? tag->fromFrame(): 0);
|
||||
frame_t last = (tag ? tag->toFrame(): editor->sprite()->lastFrame());
|
||||
|
||||
if (frameToGo > tag->toFrame())
|
||||
frameToGo = tag->fromFrame();
|
||||
|
||||
return frameToGo;
|
||||
return (frame < last ? frame+1: first);
|
||||
}
|
||||
};
|
||||
|
||||
@ -119,15 +113,12 @@ public:
|
||||
|
||||
protected:
|
||||
frame_t onGetFrame(Editor* editor) override {
|
||||
Sprite* sprite = editor->sprite();
|
||||
frame_t currentFrame = editor->frame();
|
||||
FrameTag* tag = get_animation_tag(sprite, currentFrame);
|
||||
frame_t frameToGo = currentFrame - frame_t(1);
|
||||
frame_t frame = editor->frame();
|
||||
FrameTag* tag = get_animation_tag(editor->sprite(), frame);
|
||||
frame_t first = (tag ? tag->fromFrame(): 0);
|
||||
frame_t last = (tag ? tag->toFrame(): editor->sprite()->lastFrame());
|
||||
|
||||
if (frameToGo < tag->fromFrame())
|
||||
frameToGo = tag->toFrame();
|
||||
|
||||
return frameToGo;
|
||||
return (frame > first ? frame-1: last);
|
||||
}
|
||||
};
|
||||
|
||||
@ -151,8 +142,7 @@ public:
|
||||
Command* clone() const override { return new GotoFrameCommand(*this); }
|
||||
|
||||
protected:
|
||||
void onLoadParams(const Params& params) override
|
||||
{
|
||||
void onLoadParams(const Params& params) override {
|
||||
std::string frame = params.get("frame");
|
||||
if (!frame.empty()) m_frame = strtol(frame.c_str(), NULL, 10);
|
||||
else m_frame = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user