Hearts: Don't destroy the animation handler while running it

This commit is contained in:
Gunnar Beutner 2021-06-04 10:50:40 +02:00 committed by Andreas Kling
parent fdaec58f59
commit fab9b2f068
Notes: sideshowbarker 2024-07-18 16:53:41 +09:00

View File

@ -270,8 +270,12 @@ void Game::timer_event(Core::TimerEvent&)
if (m_animation_current_step >= m_animation_steps) {
stop_timer();
m_animation_playing = false;
if (m_animation_did_finish)
(*m_animation_did_finish)();
if (m_animation_did_finish) {
// The did_finish handler might end up destroying/replacing the handler
// so we have to save it first.
OwnPtr<Function<void()>> animation_did_finish = move(m_animation_did_finish);
(*animation_did_finish)();
}
}
m_animation_current_step++;
}