diff options
author | Andreas Kling <kling@serenityos.org> | 2020-11-30 08:03:13 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-11-30 11:40:35 +0100 |
commit | 113da74683d352a412834603215f6efe70310f4c (patch) | |
tree | 8d5a7049d6a97fc5d2f84ade2af83bb6e4e6313c /Libraries/LibWeb | |
parent | 8b194f41e955a836ac952e1d02934f703fa4381f (diff) | |
download | serenity-113da74683d352a412834603215f6efe70310f4c.zip |
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. :^)
Diffstat (limited to 'Libraries/LibWeb')
-rw-r--r-- | Libraries/LibWeb/DOM/Timer.cpp | 1 | ||||
-rw-r--r-- | Libraries/LibWeb/DOM/Window.cpp | 5 | ||||
-rw-r--r-- | Libraries/LibWeb/DOM/Window.h | 1 |
3 files changed, 7 insertions, 0 deletions
diff --git a/Libraries/LibWeb/DOM/Timer.cpp b/Libraries/LibWeb/DOM/Timer.cpp index a9bf2dcd4b..04e3c778f5 100644 --- a/Libraries/LibWeb/DOM/Timer.cpp +++ b/Libraries/LibWeb/DOM/Timer.cpp @@ -54,6 +54,7 @@ Timer::Timer(Window& window, Type type, int milliseconds, JS::Function& callback Timer::~Timer() { + m_window.deallocate_timer_id({}, m_id); } } diff --git a/Libraries/LibWeb/DOM/Window.cpp b/Libraries/LibWeb/DOM/Window.cpp index e651a524ee..615d0ca679 100644 --- a/Libraries/LibWeb/DOM/Window.cpp +++ b/Libraries/LibWeb/DOM/Window.cpp @@ -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); diff --git a/Libraries/LibWeb/DOM/Window.h b/Libraries/LibWeb/DOM/Window.h index 3602b1d5c8..7de6cbacf5 100644 --- a/Libraries/LibWeb/DOM/Window.h +++ b/Libraries/LibWeb/DOM/Window.h @@ -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; } |