From f55229f8f3106101e0c2c2cb29a0dee48c2613ec Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 4 Sep 2017 12:29:10 -0300 Subject: [PATCH] Fix crash closing all files & opening a new one when preview window was playing an animation --- src/app/ui/timeline/timeline.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/app/ui/timeline/timeline.cpp b/src/app/ui/timeline/timeline.cpp index 982de444f..6eb376ef6 100644 --- a/src/app/ui/timeline/timeline.cpp +++ b/src/app/ui/timeline/timeline.cpp @@ -338,12 +338,14 @@ void Timeline::detachDocument() if (m_document) { m_thumbnailsPrefConn.disconnect(); m_document->remove_observer(this); - m_document = NULL; + m_document = nullptr; + m_sprite = nullptr; + m_layer = nullptr; } if (m_editor) { m_editor->remove_observer(this); - m_editor = NULL; + m_editor = nullptr; } invalidate(); @@ -480,19 +482,21 @@ void Timeline::activateClipboardRange() FrameTag* Timeline::getFrameTagByFrame(const frame_t frame) { - if (m_tagFocusBand < 0) { - return get_animation_tag(m_sprite, frame); - } - else { - for (FrameTag* frameTag : m_sprite->frameTags()) { - if (frame >= frameTag->fromFrame() && - frame <= frameTag->toFrame() && - m_tagBand[frameTag] == m_tagFocusBand) { - return frameTag; - } - } + if (!m_sprite) return nullptr; + + if (m_tagFocusBand < 0) + return get_animation_tag(m_sprite, frame); + + for (FrameTag* frameTag : m_sprite->frameTags()) { + if (frame >= frameTag->fromFrame() && + frame <= frameTag->toFrame() && + m_tagBand[frameTag] == m_tagFocusBand) { + return frameTag; + } } + + return nullptr; } bool Timeline::onProcessMessage(Message* msg)