mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:58:11 +00:00
LibWeb: Add GC finalizer to Layout::ImageBox
It's not safe to unregister ImageBox from the browsing context in the destructor (since the browsing context may have already been swept and destroyed).
This commit is contained in:
parent
c877eb47a2
commit
1885fe529f
2 changed files with 11 additions and 2 deletions
|
@ -18,8 +18,14 @@ ImageBox::ImageBox(DOM::Document& document, DOM::Element& element, NonnullRefPtr
|
|||
browsing_context().register_viewport_client(*this);
|
||||
}
|
||||
|
||||
ImageBox::~ImageBox()
|
||||
ImageBox::~ImageBox() = default;
|
||||
|
||||
void ImageBox::finalize()
|
||||
{
|
||||
Base::finalize();
|
||||
|
||||
// NOTE: We unregister from the browsing context in finalize() to avoid trouble
|
||||
// in the scenario where our BrowsingContext has already been swept by GC.
|
||||
browsing_context().unregister_viewport_client(*this);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue