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_secondaryButton(false)
|
||||
, m_aniSpeed(1.0)
|
||||
, m_isPlaying(false)
|
||||
{
|
||||
// Add the first state into the history.
|
||||
m_statesHistory.push(m_state);
|
||||
@ -1693,7 +1694,10 @@ void Editor::play(const bool playOnce,
|
||||
if (!m_state)
|
||||
return;
|
||||
|
||||
if (!dynamic_cast<PlayState*>(m_state.get()))
|
||||
if (m_isPlaying)
|
||||
stop();
|
||||
|
||||
m_isPlaying = true;
|
||||
setState(EditorStatePtr(new PlayState(playOnce, playAll)));
|
||||
}
|
||||
|
||||
@ -1703,13 +1707,21 @@ void Editor::stop()
|
||||
if (!m_state)
|
||||
return;
|
||||
|
||||
if (dynamic_cast<PlayState*>(m_state.get()))
|
||||
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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user