Fix crash deleting a tag that is being played in the Preview window

Fix: https://community.aseprite.org/t/consistent-crashing-when-deleting-loop-tag/1984
This commit is contained in:
David Capello 2018-09-17 15:41:28 -03:00
parent c05c3dad43
commit 22f172c932
4 changed files with 16 additions and 0 deletions

View File

@ -1950,6 +1950,8 @@ void Editor::onAddFrameTag(DocEvent& ev)
void Editor::onRemoveFrameTag(DocEvent& ev)
{
m_tagFocusBand = -1;
if (m_state)
m_state->onRemoveFrameTag(this, ev.frameTag());
}
void Editor::setCursor(const gfx::Point& mouseScreenPos)

View File

@ -22,6 +22,10 @@ namespace ui {
class TouchMessage;
}
namespace doc {
class FrameTag;
}
namespace app {
class Editor;
class EditorDecorator;
@ -117,6 +121,9 @@ namespace app {
// Custom ink in this state.
virtual tools::Ink* getStateInk() { return nullptr; }
// Called when a tag is deleted.
virtual void onRemoveFrameTag(Editor* editor, doc::FrameTag* tag) { }
private:
DISABLE_COPYING(EditorState);
};

View File

@ -167,6 +167,12 @@ bool PlayState::onSetCursor(Editor* editor, const gfx::Point& mouseScreenPos)
return true;
}
void PlayState::onRemoveFrameTag(Editor* editor, doc::FrameTag* tag)
{
if (m_tag == tag)
m_tag = nullptr;
}
void PlayState::onPlaybackTick()
{
ASSERT(m_playTimer.isRunning());

View File

@ -35,6 +35,7 @@ namespace app {
bool onKeyDown(Editor* editor, ui::KeyMessage* msg) override;
bool onKeyUp(Editor* editor, ui::KeyMessage* msg) override;
bool onSetCursor(Editor* editor, const gfx::Point& mouseScreenPos) override;
void onRemoveFrameTag(Editor* editor, doc::FrameTag* tag) override;
private:
void onPlaybackTick();