mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-01 10:21:04 +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:
parent
573a1d5791
commit
f950e2e787
@ -166,6 +166,7 @@ Editor::Editor(Document* document, EditorFlags flags)
|
|||||||
, m_flags(flags)
|
, m_flags(flags)
|
||||||
, m_secondaryButton(false)
|
, m_secondaryButton(false)
|
||||||
, m_aniSpeed(1.0)
|
, m_aniSpeed(1.0)
|
||||||
|
, m_isPlaying(false)
|
||||||
{
|
{
|
||||||
// Add the first state into the history.
|
// Add the first state into the history.
|
||||||
m_statesHistory.push(m_state);
|
m_statesHistory.push(m_state);
|
||||||
@ -1693,8 +1694,11 @@ void Editor::play(const bool playOnce,
|
|||||||
if (!m_state)
|
if (!m_state)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!dynamic_cast<PlayState*>(m_state.get()))
|
if (m_isPlaying)
|
||||||
setState(EditorStatePtr(new PlayState(playOnce, playAll)));
|
stop();
|
||||||
|
|
||||||
|
m_isPlaying = true;
|
||||||
|
setState(EditorStatePtr(new PlayState(playOnce, playAll)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::stop()
|
void Editor::stop()
|
||||||
@ -1703,13 +1707,21 @@ void Editor::stop()
|
|||||||
if (!m_state)
|
if (!m_state)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (dynamic_cast<PlayState*>(m_state.get()))
|
if (m_isPlaying) {
|
||||||
backToPreviousState();
|
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
|
bool Editor::isPlaying() const
|
||||||
{
|
{
|
||||||
return (dynamic_cast<PlayState*>(m_state.get()) != nullptr);
|
return m_isPlaying;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::showAnimationSpeedMultiplierPopup(Option<bool>& playOnce,
|
void Editor::showAnimationSpeedMultiplierPopup(Option<bool>& playOnce,
|
||||||
|
@ -331,6 +331,7 @@ namespace app {
|
|||||||
|
|
||||||
// Animation speed multiplier.
|
// Animation speed multiplier.
|
||||||
double m_aniSpeed;
|
double m_aniSpeed;
|
||||||
|
bool m_isPlaying;
|
||||||
|
|
||||||
static doc::ImageBufferPtr m_renderBuffer;
|
static doc::ImageBufferPtr m_renderBuffer;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user