mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:37:34 +00:00
Ladybird/Qt: Ensure the Inspector widget is deleted before the WebView
According to Qt documentation, destruction of a QObject's children may happen in any order. In our case, the Tab's WebContentView is deleted before its InspectorWidget. The InspectorWidget performs cleanup on that WebContentView in its destructor; this causes use-after-free since it has already been destroyed. From reading Qt threads, if a particular destruction order is required, it is okay to enforce that order with manual `delete`s. This patch does so with the InspectorWidget to ensure it is deleted before the WebContentView. Qt's object ownership is okay with this - it will remove the InspectorWidget from the Tab's children, preventing any double deletion.
This commit is contained in:
parent
a2bd19fdac
commit
c4e2c725ec
1 changed files with 4 additions and 0 deletions
|
@ -579,6 +579,10 @@ Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, St
|
|||
Tab::~Tab()
|
||||
{
|
||||
close_sub_widgets();
|
||||
|
||||
// Delete the InspectorWidget explicitly to ensure it is deleted before the WebContentView. Otherwise, Qt
|
||||
// can destroy these objects in any order, which may cause use-after-free in InspectorWidget's destructor.
|
||||
delete m_inspector_widget;
|
||||
}
|
||||
|
||||
void Tab::select_dropdown_add_item(QMenu* menu, Web::HTML::SelectItem const& item)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue