mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-23 08:00:20 +00:00
LibWeb: Clear callbacks in SharedImageRequest
after request is done
Callbacks registered within the SharedImageRequest can be removed after the request has been completed. This resolves the GC memory leak issue that occurs due to a cyclic dependency, where the callback captures the image request while being owned by the image request at the same time.
This commit is contained in:
parent
075ce53d14
commit
953c19bdb7
Notes:
sideshowbarker
2024-07-17 18:38:54 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/953c19bdb7 Pull-request: https://github.com/SerenityOS/serenity/pull/20660
1 changed files with 2 additions and 0 deletions
|
@ -160,6 +160,7 @@ void SharedImageRequest::handle_successful_fetch(AK::URL const& url_string, Stri
|
|||
if (callback.on_finish)
|
||||
callback.on_finish();
|
||||
}
|
||||
m_callbacks.clear();
|
||||
}
|
||||
|
||||
void SharedImageRequest::handle_failed_fetch()
|
||||
|
@ -169,6 +170,7 @@ void SharedImageRequest::handle_failed_fetch()
|
|||
if (callback.on_fail)
|
||||
callback.on_fail();
|
||||
}
|
||||
m_callbacks.clear();
|
||||
}
|
||||
|
||||
bool SharedImageRequest::needs_fetching() const
|
||||
|
|
Loading…
Reference in a new issue