mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
Hearts: Don't destroy the animation handler while running it
This commit is contained in:
parent
fdaec58f59
commit
fab9b2f068
1 changed files with 6 additions and 2 deletions
|
@ -270,8 +270,12 @@ void Game::timer_event(Core::TimerEvent&)
|
||||||
if (m_animation_current_step >= m_animation_steps) {
|
if (m_animation_current_step >= m_animation_steps) {
|
||||||
stop_timer();
|
stop_timer();
|
||||||
m_animation_playing = false;
|
m_animation_playing = false;
|
||||||
if (m_animation_did_finish)
|
if (m_animation_did_finish) {
|
||||||
(*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++;
|
m_animation_current_step++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue