mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibWeb: Remove some uses of [&] lambda captures for queued tasks
Using a default reference capture for these kinds of tasks is dangerous and prone to error. Some of the variables should for sure be captured by value so that we can keep a GC object alive rather than trying to refer to stack objects.
This commit is contained in:
parent
6ed2bf2bb1
commit
66519af43f
Notes:
github-actions[bot]
2024-12-10 06:14:03 +00:00
Author: https://github.com/ADKaster
Commit: 66519af43f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2860
4 changed files with 10 additions and 10 deletions
|
@ -917,7 +917,7 @@ TraversableNavigable::CheckIfUnloadingIsCanceledResult TraversableNavigable::che
|
|||
|
||||
// 5. Queue a global task on the navigation and traversal task source given traversable's active window to perform the following steps:
|
||||
VERIFY(traversable->active_window());
|
||||
queue_global_task(Task::Source::NavigationAndTraversal, *traversable->active_window(), GC::create_function(heap(), [&] {
|
||||
queue_global_task(Task::Source::NavigationAndTraversal, *traversable->active_window(), GC::create_function(heap(), [needs_beforeunload, user_involvement_for_navigate_events, traversable, target_entry, &final_status, &unload_prompt_shown, &events_fired] {
|
||||
// 1. if needsBeforeunload is true, then:
|
||||
if (needs_beforeunload) {
|
||||
// 1. Let (unloadPromptShownForThisDocument, unloadPromptCanceledByThisDocument) be the result of running the steps to fire beforeunload given traversable's active document and false.
|
||||
|
@ -971,7 +971,7 @@ TraversableNavigable::CheckIfUnloadingIsCanceledResult TraversableNavigable::che
|
|||
|
||||
// 7. For each document of documents, queue a global task on the navigation and traversal task source given document's relevant global object to run the steps:
|
||||
for (auto& document : documents_to_fire_beforeunload) {
|
||||
queue_global_task(Task::Source::NavigationAndTraversal, relevant_global_object(*document), GC::create_function(heap(), [&] {
|
||||
queue_global_task(Task::Source::NavigationAndTraversal, relevant_global_object(*document), GC::create_function(heap(), [document, &final_status, &completed_tasks, &unload_prompt_shown] {
|
||||
// 1. Let (unloadPromptShownForThisDocument, unloadPromptCanceledByThisDocument) be the result of running the steps to fire beforeunload given document and unloadPromptShown.
|
||||
auto [unload_prompt_shown_for_this_document, unload_prompt_canceled_by_this_document] = document->steps_to_fire_beforeunload(unload_prompt_shown);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue