Fix crash closing all files & opening a new one when preview window was playing an animation

This commit is contained in:
David Capello 2017-09-04 12:29:10 -03:00
parent dfa441d2a0
commit f55229f8f3

View File

@ -338,12 +338,14 @@ void Timeline::detachDocument()
if (m_document) { if (m_document) {
m_thumbnailsPrefConn.disconnect(); m_thumbnailsPrefConn.disconnect();
m_document->remove_observer(this); m_document->remove_observer(this);
m_document = NULL; m_document = nullptr;
m_sprite = nullptr;
m_layer = nullptr;
} }
if (m_editor) { if (m_editor) {
m_editor->remove_observer(this); m_editor->remove_observer(this);
m_editor = NULL; m_editor = nullptr;
} }
invalidate(); invalidate();
@ -480,19 +482,21 @@ void Timeline::activateClipboardRange()
FrameTag* Timeline::getFrameTagByFrame(const frame_t frame) FrameTag* Timeline::getFrameTagByFrame(const frame_t frame)
{ {
if (m_tagFocusBand < 0) { if (!m_sprite)
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;
}
}
return nullptr; 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) bool Timeline::onProcessMessage(Message* msg)