Fix Timeline::updateUsingEditor() as it can be called with editor=NULL

In fact, now it's called with NULL when the program starts
(see commit 517d368f938ca55f915ce9e8ffb57d96b5288b1d).
This commit is contained in:
David Capello 2013-11-23 17:09:31 -03:00
parent 6f50385d5f
commit a1f3e290c2

View File

@ -127,18 +127,20 @@ Timeline::~Timeline()
void Timeline::updateUsingEditor(Editor* editor) void Timeline::updateUsingEditor(Editor* editor)
{ {
DocumentView* view = editor->getDocumentView(); detachDocument();
DocumentLocation location;
view->getDocumentLocation(&location);
if (m_editor)
m_editor->removeObserver(this);
// We always update the editor. In this way the timeline keeps in // We always update the editor. In this way the timeline keeps in
// sync with the active editor. // sync with the active editor.
m_editor = editor; m_editor = editor;
if (m_editor) if (m_editor)
m_editor->addObserver(this); m_editor->addObserver(this);
else
return; // No editor specified.
DocumentLocation location;
DocumentView* view = m_editor->getDocumentView();
view->getDocumentLocation(&location);
// If we are already in the same position as the "editor", we don't // If we are already in the same position as the "editor", we don't
// need to update the at all timeline. // need to update the at all timeline.
@ -148,8 +150,6 @@ void Timeline::updateUsingEditor(Editor* editor)
m_frame == location.frame()) m_frame == location.frame())
return; return;
detachDocument();
m_document = location.document(); m_document = location.document();
m_sprite = location.sprite(); m_sprite = location.sprite();
m_layer = location.layer(); m_layer = location.layer();