mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 06:48:49 +00:00
LibHTML: Ignore completed image loads for already-destroyed <img>'s
Capture a weak pointer to the element and pass that to the load finish callback in HTMLImageElement::load_image(). This allows us to ignore completed loads if the <img> element is no longer around.
This commit is contained in:
parent
877ff6bc13
commit
a5f3f332ed
Notes:
sideshowbarker
2024-07-19 11:38:38 +09:00
Author: https://github.com/awesomekling
Commit: a5f3f332ed
1 changed files with 5 additions and 1 deletions
|
@ -23,7 +23,11 @@ void HTMLImageElement::parse_attribute(const String& name, const String& value)
|
|||
void HTMLImageElement::load_image(const String& src)
|
||||
{
|
||||
URL src_url = document().complete_url(src);
|
||||
ResourceLoader::the().load(src_url, [this](auto data) {
|
||||
ResourceLoader::the().load(src_url, [this, weak_element = make_weak_ptr()](auto data) {
|
||||
if (!weak_element) {
|
||||
dbg() << "HTMLImageElement: Load completed after element destroyed.";
|
||||
return;
|
||||
}
|
||||
if (data.is_null()) {
|
||||
dbg() << "HTMLImageElement: Failed to load " << this->src();
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue