mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
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
|
@ -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…
Reference in a new issue