Fix bug "Rewind on Stop" increments start frame randomly (fix #1569)

This commit is contained in:
David Capello 2017-09-08 11:20:55 -03:00
parent 49d2cd14f0
commit 7b7b12b593
2 changed files with 15 additions and 7 deletions

View File

@ -92,13 +92,13 @@ void PlayState::onEnterState(Editor* editor)
EditorState::LeaveAction PlayState::onLeaveState(Editor* editor, EditorState* newState)
{
// We don't stop the timer if we are going to the ScrollingState
// (we keep playing the animation).
if (!m_toScroll) {
m_playTimer.stop();
if (m_playOnce || Preferences::instance().general.rewindOnStop())
m_editor->setFrame(m_refFrame);
// We don't stop the timer if we are going to the ScrollingState
// (we keep playing the animation).
m_playTimer.stop();
}
return KeepState;
}
@ -169,6 +169,8 @@ bool PlayState::onSetCursor(Editor* editor, const gfx::Point& mouseScreenPos)
void PlayState::onPlaybackTick()
{
ASSERT(m_playTimer.isRunning());
if (m_nextFrameTime < 0)
return;

View File

@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2001-2016 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -41,8 +41,8 @@ Timer::~Timer()
ASSERT(it != timers.end());
timers.erase(it);
// Remove messages of this timer in the queue
Manager::getDefault()->removeMessagesForTimer(this);
// Stop the timer and remove it from the message queue.
stop();
}
void Timer::start()
@ -54,6 +54,12 @@ void Timer::start()
void Timer::stop()
{
m_running = false;
// Remove messages of this timer in the queue. The expected behavior
// is that when we stop a timer, we'll not receive more messages
// about it (even if there are enqueued messages waiting in the
// message queue).
Manager::getDefault()->removeMessagesForTimer(this);
}
void Timer::tick()