Hearts: Don't destroy the animation handler while running it
This commit is contained in:
parent
fdaec58f59
commit
fab9b2f068
Notes:
sideshowbarker
2024-07-18 16:53:41 +09:00
Author: https://github.com/gunnarbeutner Commit: https://github.com/SerenityOS/serenity/commit/fab9b2f068c Pull-request: https://github.com/SerenityOS/serenity/pull/7774
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) {
|
||||
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++;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue