LibWeb: Use HeapFunction for Platform::Timer

This commit is contained in:
Shannon Booth 2024-10-30 21:42:05 +13:00 committed by Alexander Kalenik
commit de1a805898
Notes: github-actions[bot] 2024-10-30 19:57:21 +00:00
8 changed files with 28 additions and 18 deletions

View file

@ -415,12 +415,12 @@ void ResourceLoader::load(LoadRequest& request, SuccessCallback success_callback
if (timeout.has_value() && timeout.value() > 0) {
auto timer = Platform::Timer::create_single_shot(m_heap, timeout.value(), nullptr);
timer->on_timeout = [timer, protocol_request, timeout_callback = move(timeout_callback)] {
timer->on_timeout = JS::create_heap_function(m_heap, [timer = JS::make_handle(timer), protocol_request, timeout_callback = move(timeout_callback)] {
(void)timer;
protocol_request->stop();
if (timeout_callback)
timeout_callback();
};
});
timer->start();
}