mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-04 08:46:09 +00:00
Fix crash if we remove a tag when we're playing the animation
This commit is contained in:
parent
9601c02812
commit
6c2d2f6f79
@ -192,6 +192,8 @@ void PlayState::onRemoveTag(Editor* editor, doc::Tag* tag)
|
||||
{
|
||||
if (m_tag == tag)
|
||||
m_tag = nullptr;
|
||||
|
||||
m_playback.removeReferencesToTag(tag);
|
||||
}
|
||||
|
||||
void PlayState::onPlaybackTick()
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "doc/playback.h"
|
||||
|
||||
#include "base/remove_from_container.h"
|
||||
#include "doc/frame.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "doc/tag.h"
|
||||
@ -144,6 +145,20 @@ Tag* Playback::tag() const
|
||||
return (!m_playing.empty() ? const_cast<Tag*>(m_playing.back()->tag): nullptr);
|
||||
}
|
||||
|
||||
void Playback::removeReferencesToTag(Tag* tag)
|
||||
{
|
||||
base::remove_from_container(m_tags, tag);
|
||||
base::remove_from_container(m_played, tag);
|
||||
|
||||
for (auto it=m_playing.begin(); it!=m_playing.end(); ) {
|
||||
std::unique_ptr<PlayTag>& playTag = *it;
|
||||
if (playTag->tag == tag)
|
||||
it = m_playing.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
void Playback::handleEnterFrame(const frame_t frameDelta, const bool firstTime)
|
||||
{
|
||||
PLAY_TRACE(" handleEnterFrame", m_frame, "+", frameDelta);
|
||||
|
@ -76,6 +76,10 @@ namespace doc {
|
||||
// The tag that is being played right now (can be nullptr).
|
||||
Tag* tag() const;
|
||||
|
||||
// Should be called when a specific tag is going to be deleted so
|
||||
// we remove all references to this tag.
|
||||
void removeReferencesToTag(Tag* tag);
|
||||
|
||||
private:
|
||||
// Information about playing tags (and inner tags)
|
||||
struct PlayTag {
|
||||
|
Loading…
Reference in New Issue
Block a user