From 2dca24229bf35ffb0d38586c77e3f32a02bb4160 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" <277429+mackal@users.noreply.github.com> Date: Tue, 4 Apr 2023 15:59:45 -0400 Subject: [PATCH 1/4] DolphinQt: Fix memory lkea in FilesystemWidget QTreeView::setModel doesn't transfer ownership of the object. Setting the parent resolves this --- Source/Core/DolphinQt/Config/FilesystemWidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Core/DolphinQt/Config/FilesystemWidget.cpp b/Source/Core/DolphinQt/Config/FilesystemWidget.cpp index d9d053f0b1..6fefcdc1ee 100644 --- a/Source/Core/DolphinQt/Config/FilesystemWidget.cpp +++ b/Source/Core/DolphinQt/Config/FilesystemWidget.cpp @@ -62,6 +62,7 @@ void FilesystemWidget::CreateWidgets() m_tree_view = new QTreeView(this); m_tree_view->setModel(m_tree_model); m_tree_view->setContextMenuPolicy(Qt::CustomContextMenu); + m_tree_model->setParent(m_tree_view); auto* header = m_tree_view->header(); From e511718fbc9207284bc5d109bc1d958476fe104b Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" <277429+mackal@users.noreply.github.com> Date: Tue, 4 Apr 2023 16:05:23 -0400 Subject: [PATCH 2/4] DolphinQt: Fix leak in LogConfigWidget The m_verbosity_debug button was only conditionally being added as widget, this was done in order to hide the object, but this left it unmanaged. Unconditionally adding it to the layout and controlling it's visibility will resolve these issues --- Source/Core/DolphinQt/Config/LogConfigWidget.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Source/Core/DolphinQt/Config/LogConfigWidget.cpp b/Source/Core/DolphinQt/Config/LogConfigWidget.cpp index dab59e63d9..607d3618c2 100644 --- a/Source/Core/DolphinQt/Config/LogConfigWidget.cpp +++ b/Source/Core/DolphinQt/Config/LogConfigWidget.cpp @@ -47,6 +47,7 @@ void LogConfigWidget::CreateWidgets() m_verbosity_warning = new QRadioButton(tr("Warning")); m_verbosity_info = new QRadioButton(tr("Info")); m_verbosity_debug = new QRadioButton(tr("Debug")); + m_verbosity_debug->setVisible(Common::Log::MAX_LOGLEVEL == Common::Log::LogLevel::LDEBUG); auto* outputs = new QGroupBox(tr("Logger Outputs")); auto* outputs_layout = new QVBoxLayout; @@ -77,10 +78,7 @@ void LogConfigWidget::CreateWidgets() verbosity_layout->addWidget(m_verbosity_error); verbosity_layout->addWidget(m_verbosity_warning); verbosity_layout->addWidget(m_verbosity_info); - if constexpr (Common::Log::MAX_LOGLEVEL == Common::Log::LogLevel::LDEBUG) - { - verbosity_layout->addWidget(m_verbosity_debug); - } + verbosity_layout->addWidget(m_verbosity_debug); layout->addWidget(outputs); outputs_layout->addWidget(m_out_file); From 7dde0c3c319577fd913e4de72a6113a8998ada49 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" <277429+mackal@users.noreply.github.com> Date: Tue, 4 Apr 2023 16:07:06 -0400 Subject: [PATCH 3/4] DolphinQt: non-Windows builds leak in InterfacePane The m_checkbox_lock_mouse QCheckBox was only conditionally being added to the layout, leaving it unmanaged and leaking Setting the parent will allow it to be managed. --- Source/Core/DolphinQt/Settings/InterfacePane.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Core/DolphinQt/Settings/InterfacePane.cpp b/Source/Core/DolphinQt/Settings/InterfacePane.cpp index f7590872cf..9365795551 100644 --- a/Source/Core/DolphinQt/Settings/InterfacePane.cpp +++ b/Source/Core/DolphinQt/Settings/InterfacePane.cpp @@ -189,7 +189,8 @@ void InterfacePane::CreateInGame() m_vboxlayout_hide_mouse->addWidget(m_radio_cursor_visible_never); m_vboxlayout_hide_mouse->addWidget(m_radio_cursor_visible_always); - m_checkbox_lock_mouse = new QCheckBox(tr("Lock Mouse Cursor")); + // this ends up not being managed unless _WIN32, so lets not leak + m_checkbox_lock_mouse = new QCheckBox(tr("Lock Mouse Cursor"), this); m_checkbox_lock_mouse->setToolTip(tr("Will lock the Mouse Cursor to the Render Widget as long as " "it has focus. You can set a hotkey to unlock it.")); From f424e7815aa6b3223ebbc4d028932a970b546f77 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" <277429+mackal@users.noreply.github.com> Date: Tue, 4 Apr 2023 16:10:31 -0400 Subject: [PATCH 4/4] DolphinQt: Fix memory leaks in MemoryWidget QMenuBar::addMenu does not take ownership of the QMenu, setting their parent allows them to be cleaned up --- Source/Core/DolphinQt/Debugger/MemoryWidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp b/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp index 0c3646ec7a..34dd7b767e 100644 --- a/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp @@ -249,12 +249,12 @@ void MemoryWidget::CreateWidgets() QMenuBar* menubar = new QMenuBar(sidebar); menubar->setNativeMenuBar(false); - QMenu* menu_import = new QMenu(tr("&Import")); + QMenu* menu_import = new QMenu(tr("&Import"), menubar); menu_import->addAction(tr("&Load file to current address"), this, &MemoryWidget::OnSetValueFromFile); menubar->addMenu(menu_import); - QMenu* menu_export = new QMenu(tr("&Export")); + QMenu* menu_export = new QMenu(tr("&Export"), menubar); menu_export->addAction(tr("Dump &MRAM"), this, &MemoryWidget::OnDumpMRAM); menu_export->addAction(tr("Dump &ExRAM"), this, &MemoryWidget::OnDumpExRAM); menu_export->addAction(tr("Dump &ARAM"), this, &MemoryWidget::OnDumpARAM);