From 919033fffd8b3e96ae29a23806c07bc15d6ad48b Mon Sep 17 00:00:00 2001 From: Sebastian Zaha Date: Wed, 19 Jul 2023 18:07:50 +0200 Subject: [PATCH] Ladybird: Prevent QAction leaking In some places in the code QAction instances are added to a parent directly on instantiation. In the case they are not, Valgrind reports them as leaking. --- Ladybird/BrowserWindow.cpp | 6 +++--- Ladybird/Tab.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Ladybird/BrowserWindow.cpp b/Ladybird/BrowserWindow.cpp index 036514cc62..4f3bcf2c26 100644 --- a/Ladybird/BrowserWindow.cpp +++ b/Ladybird/BrowserWindow.cpp @@ -182,7 +182,7 @@ BrowserWindow::BrowserWindow(Browser::CookieJar& cookie_jar, StringView webdrive } }); - auto* inspector_action = new QAction("Open &Inspector"); + auto* inspector_action = new QAction("Open &Inspector", this); inspector_action->setIcon(QIcon(QString("%1/res/icons/browser/dom-tree.png").arg(s_serenity_resource_root.characters()))); inspector_action->setShortcut(QKeySequence("Ctrl+Shift+I")); inspect_menu->addAction(inspector_action); @@ -292,7 +292,7 @@ BrowserWindow::BrowserWindow(Browser::CookieJar& cookie_jar, StringView webdrive auto* user_agent_group = new QActionGroup(this); auto add_user_agent = [this, &user_agent_group, &spoof_user_agent_menu](auto& name, auto& user_agent) { - auto* action = new QAction(name); + auto* action = new QAction(name, this); action->setCheckable(true); user_agent_group->addAction(action); spoof_user_agent_menu->addAction(action); @@ -312,7 +312,7 @@ BrowserWindow::BrowserWindow(Browser::CookieJar& cookie_jar, StringView webdrive add_user_agent("Firefox Android Mobile", "Mozilla/5.0 (Android 11; Mobile; rv:68.0) Gecko/68.0 Firefox/86.0"); add_user_agent("Safari iOS Mobile", "Mozilla/5.0 (iPhone; CPU iPhone OS 14_4_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1"); - auto* custom_user_agent_action = new QAction("Custom..."); + auto* custom_user_agent_action = new QAction("Custom...", this); custom_user_agent_action->setCheckable(true); user_agent_group->addAction(custom_user_agent_action); spoof_user_agent_menu->addAction(custom_user_agent_action); diff --git a/Ladybird/Tab.cpp b/Ladybird/Tab.cpp index e5ced63acd..4fe76ffa4e 100644 --- a/Ladybird/Tab.cpp +++ b/Ladybird/Tab.cpp @@ -78,7 +78,7 @@ Tab::Tab(BrowserWindow* window, StringView webdriver_content_ipc_path, WebView:: m_hover_label->setFrameShape(QFrame::Shape::Box); m_hover_label->setAutoFillBackground(true); - auto* focus_location_editor_action = new QAction("Edit Location"); + auto* focus_location_editor_action = new QAction("Edit Location", this); focus_location_editor_action->setShortcut(QKeySequence("Ctrl+L")); addAction(focus_location_editor_action);