mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibWeb: Deallocate DOM timer ID's when the timer goes away
I left a page open overnight and it had run out of timer ID's. :^)
This commit is contained in:
parent
8b194f41e9
commit
113da74683
Notes:
sideshowbarker
2024-07-19 01:09:48 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/113da74683d
3 changed files with 7 additions and 0 deletions
|
@ -54,6 +54,7 @@ Timer::Timer(Window& window, Type type, int milliseconds, JS::Function& callback
|
|||
|
||||
Timer::~Timer()
|
||||
{
|
||||
m_window.deallocate_timer_id({}, m_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -108,6 +108,11 @@ i32 Window::allocate_timer_id(Badge<Timer>)
|
|||
return m_timer_id_allocator.allocate();
|
||||
}
|
||||
|
||||
void Window::deallocate_timer_id(Badge<Timer>, i32 id)
|
||||
{
|
||||
m_timer_id_allocator.deallocate(id);
|
||||
}
|
||||
|
||||
void Window::clear_timeout(i32 timer_id)
|
||||
{
|
||||
m_timers.remove(timer_id);
|
||||
|
|
|
@ -74,6 +74,7 @@ public:
|
|||
void set_wrapper(Badge<Bindings::WindowObject>, Bindings::WindowObject&);
|
||||
|
||||
i32 allocate_timer_id(Badge<Timer>);
|
||||
void deallocate_timer_id(Badge<Timer>, i32);
|
||||
void timer_did_fire(Badge<Timer>, Timer&);
|
||||
|
||||
HighResolutionTime::Performance& performance() { return *m_performance; }
|
||||
|
|
Loading…
Add table
Reference in a new issue