mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 01:17:36 +00:00
LibWeb: Don't access SharedImageRequest::m_document in destructor
It's not safe to access m_document here since GC may have deleted it by the time we're being deleted. Instead, move this to a finalize() override, since those are guaranteed to be called while both objects are still alive.
This commit is contained in:
parent
6c1fcc5f7e
commit
41941aeb10
2 changed files with 9 additions and 5 deletions
|
@ -40,8 +40,11 @@ SharedImageRequest::SharedImageRequest(JS::NonnullGCPtr<Page> page, AK::URL url,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedImageRequest::~SharedImageRequest()
|
SharedImageRequest::~SharedImageRequest() = default;
|
||||||
|
|
||||||
|
void SharedImageRequest::finalize()
|
||||||
{
|
{
|
||||||
|
Base::finalize();
|
||||||
auto& shared_image_requests = m_document->shared_image_requests();
|
auto& shared_image_requests = m_document->shared_image_requests();
|
||||||
shared_image_requests.remove(m_url);
|
shared_image_requests.remove(m_url);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,14 +17,14 @@
|
||||||
|
|
||||||
namespace Web::HTML {
|
namespace Web::HTML {
|
||||||
|
|
||||||
class SharedImageRequest : public JS::Cell {
|
class SharedImageRequest final : public JS::Cell {
|
||||||
JS_CELL(ImageRequest, JS::Cell);
|
JS_CELL(ImageRequest, JS::Cell);
|
||||||
JS_DECLARE_ALLOCATOR(SharedImageRequest);
|
JS_DECLARE_ALLOCATOR(SharedImageRequest);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] static JS::NonnullGCPtr<SharedImageRequest> get_or_create(JS::Realm&, JS::NonnullGCPtr<Page>, AK::URL const&);
|
[[nodiscard]] static JS::NonnullGCPtr<SharedImageRequest> get_or_create(JS::Realm&, JS::NonnullGCPtr<Page>, AK::URL const&);
|
||||||
|
|
||||||
~SharedImageRequest();
|
virtual ~SharedImageRequest() override;
|
||||||
|
|
||||||
AK::URL const& url() const { return m_url; }
|
AK::URL const& url() const { return m_url; }
|
||||||
|
|
||||||
|
@ -40,11 +40,12 @@ public:
|
||||||
bool is_fetching() const;
|
bool is_fetching() const;
|
||||||
bool needs_fetching() const;
|
bool needs_fetching() const;
|
||||||
|
|
||||||
virtual void visit_edges(JS::Cell::Visitor&) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit SharedImageRequest(JS::NonnullGCPtr<Page>, AK::URL, JS::NonnullGCPtr<DOM::Document>);
|
explicit SharedImageRequest(JS::NonnullGCPtr<Page>, AK::URL, JS::NonnullGCPtr<DOM::Document>);
|
||||||
|
|
||||||
|
virtual void finalize() override;
|
||||||
|
virtual void visit_edges(JS::Cell::Visitor&) override;
|
||||||
|
|
||||||
void handle_successful_fetch(AK::URL const&, StringView mime_type, ByteBuffer data);
|
void handle_successful_fetch(AK::URL const&, StringView mime_type, ByteBuffer data);
|
||||||
void handle_failed_fetch();
|
void handle_failed_fetch();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue