From 869d2f5443e1ac77f82c4b37f3161ee2536f56f4 Mon Sep 17 00:00:00 2001 From: Xusheng Date: Fri, 10 Apr 2026 09:52:20 +0800 Subject: [PATCH 1/2] Fix AttachProcessDialog leak causing DebuggerController ref leak AttachProcessDialog was heap-allocated but never freed. Since it owns a ProcessListWidget which holds a DbgRef, this also caused the controller to leak. Add deleteLater() calls on all exit paths after the dialog is used. Fix https://github.com/Vector35/debugger/issues/1061 Co-Authored-By: Claude Opus 4.6 --- ui/ui.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/ui.cpp b/ui/ui.cpp index 1ebebd1f..c72ab6de 100644 --- a/ui/ui.cpp +++ b/ui/ui.cpp @@ -857,9 +857,13 @@ void GlobalDebuggerUI::SetupMenu(UIContext* context) auto dialog = new AttachProcessDialog(context->mainWindow(), controller); if (dialog->exec() != QDialog::Accepted) + { + dialog->deleteLater(); return; + } uint32_t pid = dialog->GetSelectedPid(); + dialog->deleteLater(); if (pid == 0) return; From 57c16912b8b56ac1bf85406bf60adbab80698639 Mon Sep 17 00:00:00 2001 From: Xusheng Date: Fri, 10 Apr 2026 21:50:32 +0800 Subject: [PATCH 2/2] Use stack allocation for AttachProcessDialog Address review feedback: switch from heap allocation with deleteLater() to stack allocation, which handles cleanup automatically. Co-Authored-By: Claude Opus 4.6 --- ui/ui.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/ui/ui.cpp b/ui/ui.cpp index c72ab6de..0920167b 100644 --- a/ui/ui.cpp +++ b/ui/ui.cpp @@ -855,15 +855,11 @@ void GlobalDebuggerUI::SetupMenu(UIContext* context) return; } - auto dialog = new AttachProcessDialog(context->mainWindow(), controller); - if (dialog->exec() != QDialog::Accepted) - { - dialog->deleteLater(); + AttachProcessDialog dialog(context->mainWindow(), controller); + if (dialog.exec() != QDialog::Accepted) return; - } - uint32_t pid = dialog->GetSelectedPid(); - dialog->deleteLater(); + uint32_t pid = dialog.GetSelectedPid(); if (pid == 0) return;