mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:27:35 +00:00
LibWeb: Use Core::Timer instead of Platform::Timer in HTML::Timer
By using Core::Timer that accepts Function instead of JS::SafeFunction in Platform::Timer does we fix memory leak caused by circular dependency of timer's callback and timer itself.
This commit is contained in:
parent
67c727177e
commit
883a97984c
2 changed files with 4 additions and 4 deletions
|
@ -4,10 +4,10 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibCore/Timer.h>
|
||||||
#include <LibJS/Runtime/Object.h>
|
#include <LibJS/Runtime/Object.h>
|
||||||
#include <LibWeb/HTML/Timer.h>
|
#include <LibWeb/HTML/Timer.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
#include <LibWeb/HTML/Window.h>
|
||||||
#include <LibWeb/Platform/Timer.h>
|
|
||||||
|
|
||||||
namespace Web::HTML {
|
namespace Web::HTML {
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ Timer::Timer(JS::Object& window_or_worker_global_scope, i32 milliseconds, Functi
|
||||||
, m_callback(move(callback))
|
, m_callback(move(callback))
|
||||||
, m_id(id)
|
, m_id(id)
|
||||||
{
|
{
|
||||||
m_timer = Platform::Timer::create_single_shot(milliseconds, [this] {
|
m_timer = Core::Timer::create_single_shot(milliseconds, [this] {
|
||||||
m_callback();
|
m_callback();
|
||||||
});
|
}).release_value_but_fixme_should_propagate_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Timer::visit_edges(Cell::Visitor& visitor)
|
void Timer::visit_edges(Cell::Visitor& visitor)
|
||||||
|
|
|
@ -31,7 +31,7 @@ private:
|
||||||
|
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
RefPtr<Platform::Timer> m_timer;
|
RefPtr<Core::Timer> m_timer;
|
||||||
JS::NonnullGCPtr<JS::Object> m_window_or_worker_global_scope;
|
JS::NonnullGCPtr<JS::Object> m_window_or_worker_global_scope;
|
||||||
Function<void()> m_callback;
|
Function<void()> m_callback;
|
||||||
i32 m_id { 0 };
|
i32 m_id { 0 };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue