Avoid setting invalid frame on Editor in certain cases

Playback is still buggy, and we need to fix some test cases, but this
is useful to fix a crash/assert fail if we try to set as active frame
something outside the valid range.
This commit is contained in:
David Capello 2022-10-24 16:19:25 -03:00
parent b21831561a
commit 69d3ada204

View File

@ -207,7 +207,11 @@ void PlayState::onPlaybackTick()
while (m_nextFrameTime <= 0) {
doc::frame_t frame = m_playback.nextFrame();
if (m_playback.isStopped()) {
if (m_playback.isStopped() ||
// TODO invalid frame from Playback::nextFrame(), in this way
// we avoid any kind of crash or assert fail
frame < 0 || frame > m_editor->sprite()->lastFrame()) {
TRACEARGS("!!! PlayState: invalid frame from Playback::nextFrame() frame=", frame);
m_editor->stop();
break;
}