1
0
mirror of https://github.com/aseprite/aseprite.git synced 2025-03-30 22:21:12 +00:00

Fix bug entering multiple times to PlayState

If we pressed Enter key when we were scrolling in the
PlayState (e.g. with middle-click), we could stack other PlayState, and
so on.
This commit is contained in:
David Capello 2016-12-07 08:40:08 -03:00
parent 573a1d5791
commit f950e2e787
2 changed files with 18 additions and 5 deletions
src/app/ui/editor

@ -166,6 +166,7 @@ Editor::Editor(Document* document, EditorFlags flags)
, m_flags(flags)
, m_secondaryButton(false)
, m_aniSpeed(1.0)
, m_isPlaying(false)
{
// Add the first state into the history.
m_statesHistory.push(m_state);
@ -1693,8 +1694,11 @@ void Editor::play(const bool playOnce,
if (!m_state)
return;
if (!dynamic_cast<PlayState*>(m_state.get()))
setState(EditorStatePtr(new PlayState(playOnce, playAll)));
if (m_isPlaying)
stop();
m_isPlaying = true;
setState(EditorStatePtr(new PlayState(playOnce, playAll)));
}
void Editor::stop()
@ -1703,13 +1707,21 @@ void Editor::stop()
if (!m_state)
return;
if (dynamic_cast<PlayState*>(m_state.get()))
backToPreviousState();
if (m_isPlaying) {
while (m_state && !dynamic_cast<PlayState*>(m_state.get()))
backToPreviousState();
m_isPlaying = false;
ASSERT(m_state && dynamic_cast<PlayState*>(m_state.get()));
if (m_state)
backToPreviousState();
}
}
bool Editor::isPlaying() const
{
return (dynamic_cast<PlayState*>(m_state.get()) != nullptr);
return m_isPlaying;
}
void Editor::showAnimationSpeedMultiplierPopup(Option<bool>& playOnce,

@ -331,6 +331,7 @@ namespace app {
// Animation speed multiplier.
double m_aniSpeed;
bool m_isPlaying;
static doc::ImageBufferPtr m_renderBuffer;