mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 13:19:05 +00:00
LibWeb: Set module map entry before invoking callbacks
This patch fixes the value of a module map entry being wrong in the callbacks invoked in the set call. Previously we would set the value in only after invoking the callbacks, leading to crashes when a callback implementation would rightfully assume the value to be set already. Resolves #20994
This commit is contained in:
parent
169d24ae2e
commit
0388766531
Notes:
sideshowbarker
2024-07-16 23:23:26 +09:00
Author: https://github.com/networkException
Commit: 0388766531
Pull-request: https://github.com/SerenityOS/serenity/pull/21586
Issue: https://github.com/SerenityOS/serenity/issues/20994
1 changed files with 4 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2022, networkException <networkexception@serenityos.org>
|
* Copyright (c) 2022-2023, networkException <networkexception@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -42,12 +42,14 @@ Optional<ModuleMap::Entry> ModuleMap::get(AK::URL const& url, DeprecatedString c
|
||||||
|
|
||||||
AK::HashSetResult ModuleMap::set(AK::URL const& url, DeprecatedString const& type, Entry entry)
|
AK::HashSetResult ModuleMap::set(AK::URL const& url, DeprecatedString const& type, Entry entry)
|
||||||
{
|
{
|
||||||
|
auto value = m_values.set({ url, type }, entry);
|
||||||
|
|
||||||
auto callbacks = m_callbacks.get({ url, type });
|
auto callbacks = m_callbacks.get({ url, type });
|
||||||
if (callbacks.has_value())
|
if (callbacks.has_value())
|
||||||
for (auto const& callback : *callbacks)
|
for (auto const& callback : *callbacks)
|
||||||
callback(entry);
|
callback(entry);
|
||||||
|
|
||||||
return m_values.set({ url, type }, entry);
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleMap::wait_for_change(AK::URL const& url, DeprecatedString const& type, Function<void(Entry)> callback)
|
void ModuleMap::wait_for_change(AK::URL const& url, DeprecatedString const& type, Function<void(Entry)> callback)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue