From 13b0f4a24ca44b55920979e9d0ec8b5cf4745e38 Mon Sep 17 00:00:00 2001 From: chaoticgd <43898262+chaoticgd@users.noreply.github.com> Date: Mon, 24 Nov 2025 17:41:28 +0000 Subject: [PATCH] Debugger: Replace calls to QDialog::exec with QDialog::open --- pcsx2-qt/Debugger/DisassemblyView.cpp | 9 ++-- pcsx2-qt/Debugger/Docking/DockManager.cpp | 47 +++++++++++-------- .../Debugger/SymbolTree/SymbolTreeViews.cpp | 24 ++++++---- 3 files changed, 50 insertions(+), 30 deletions(-) diff --git a/pcsx2-qt/Debugger/DisassemblyView.cpp b/pcsx2-qt/Debugger/DisassemblyView.cpp index 1f033f640e..7cc900ee0c 100644 --- a/pcsx2-qt/Debugger/DisassemblyView.cpp +++ b/pcsx2-qt/Debugger/DisassemblyView.cpp @@ -265,13 +265,16 @@ void DisassemblyView::contextGoToAddress() void DisassemblyView::contextAddFunction() { NewFunctionDialog* dialog = new NewFunctionDialog(cpu(), this); - dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->setName(QString("func_%1").arg(m_selectedAddressStart, 8, 16, QChar('0'))); dialog->setAddress(m_selectedAddressStart); + dialog->setAttribute(Qt::WA_DeleteOnClose); + if (m_selectedAddressEnd != m_selectedAddressStart) dialog->setCustomSize(m_selectedAddressEnd - m_selectedAddressStart + 4); - if (dialog->exec() == QDialog::Accepted) - update(); + + connect(dialog, &QDialog::accepted, this, [this]() { update(); }); + + dialog->open(); } void DisassemblyView::contextCopyFunctionName() diff --git a/pcsx2-qt/Debugger/Docking/DockManager.cpp b/pcsx2-qt/Debugger/Docking/DockManager.cpp index d2509619f4..5eef7859fc 100644 --- a/pcsx2-qt/Debugger/Docking/DockManager.cpp +++ b/pcsx2-qt/Debugger/Docking/DockManager.cpp @@ -518,17 +518,19 @@ void DockManager::newLayoutClicked() if (m_menu_bar) m_menu_bar->onCurrentLayoutChanged(m_current_layout); - auto name_validator = [this](const QString& name) { + const auto name_validator = [this](const QString& name) { return !hasNameConflict(name, DockLayout::INVALID_INDEX); }; - bool can_clone_current_layout = m_current_layout != DockLayout::INVALID_INDEX; + const bool can_clone_current_layout = m_current_layout != DockLayout::INVALID_INDEX; - QPointer dialog = new LayoutEditorDialog( - name_validator, can_clone_current_layout, g_debugger_window); + LayoutEditorDialog* dialog = new LayoutEditorDialog(name_validator, can_clone_current_layout, g_debugger_window); + dialog->setAttribute(Qt::WA_DeleteOnClose); + + connect(dialog, &QDialog::accepted, this, [this, dialog, name_validator]() { + if (!name_validator(dialog->name())) + return; - if (dialog->exec() == QDialog::Accepted && name_validator(dialog->name())) - { DockLayout::Index new_layout = DockLayout::INVALID_INDEX; const auto [mode, index] = dialog->initialState(); @@ -565,9 +567,9 @@ void DockManager::newLayoutClicked() updateLayoutSwitcher(); switchToLayout(new_layout); } - } + }); - delete dialog.get(); + dialog->open(); } void DockManager::openLayoutSwitcherContextMenu(const QPoint& pos, QTabBar* layout_switcher) @@ -605,26 +607,33 @@ void DockManager::editLayoutClicked(DockLayout::Index layout_index) if (layout_index >= m_layouts.size()) return; - DockLayout& layout = m_layouts[layout_index]; + const DockLayout& layout = m_layouts[layout_index]; - auto name_validator = [this, layout_index](const QString& name) { + const auto name_validator = [this, layout_index](const QString& name) { return !hasNameConflict(name, layout_index); }; - QPointer dialog = new LayoutEditorDialog( - layout.name(), layout.cpu(), name_validator, g_debugger_window); + LayoutEditorDialog* dialog = new LayoutEditorDialog(layout.name(), layout.cpu(), name_validator, g_debugger_window); + dialog->setAttribute(Qt::WA_DeleteOnClose); - if (dialog->exec() != QDialog::Accepted || !name_validator(dialog->name())) - return; + connect(dialog, &QDialog::accepted, this, [this, layout_index, dialog, name_validator]() { + if (layout_index >= m_layouts.size()) + return; - layout.setName(dialog->name()); - layout.setCpu(dialog->cpu()); + DockLayout& layout = m_layouts[layout_index]; - layout.save(layout_index); + if (!name_validator(dialog->name())) + return; - delete dialog.get(); + layout.setName(dialog->name()); + layout.setCpu(dialog->cpu()); - updateLayoutSwitcher(); + layout.save(layout_index); + + updateLayoutSwitcher(); + }); + + dialog->open(); } void DockManager::resetLayoutClicked(DockLayout::Index layout_index) diff --git a/pcsx2-qt/Debugger/SymbolTree/SymbolTreeViews.cpp b/pcsx2-qt/Debugger/SymbolTree/SymbolTreeViews.cpp index efc977873c..1c6e986abe 100644 --- a/pcsx2-qt/Debugger/SymbolTree/SymbolTreeViews.cpp +++ b/pcsx2-qt/Debugger/SymbolTree/SymbolTreeViews.cpp @@ -857,8 +857,10 @@ void FunctionTreeView::onNewButtonPressed() { NewFunctionDialog* dialog = new NewFunctionDialog(cpu(), this); dialog->setAttribute(Qt::WA_DeleteOnClose); - if (dialog->exec() == QDialog::Accepted) - reset(); + + connect(dialog, &QDialog::accepted, this, &FunctionTreeView::reset); + + dialog->open(); } // ***************************************************************************** @@ -1000,8 +1002,10 @@ void GlobalVariableTreeView::onNewButtonPressed() { NewGlobalVariableDialog* dialog = new NewGlobalVariableDialog(cpu(), this); dialog->setAttribute(Qt::WA_DeleteOnClose); - if (dialog->exec() == QDialog::Accepted) - reset(); + + connect(dialog, &QDialog::accepted, this, &GlobalVariableTreeView::reset); + + dialog->open(); } // ***************************************************************************** @@ -1129,8 +1133,10 @@ void LocalVariableTreeView::onNewButtonPressed() { NewLocalVariableDialog* dialog = new NewLocalVariableDialog(cpu(), this); dialog->setAttribute(Qt::WA_DeleteOnClose); - if (dialog->exec() == QDialog::Accepted) - reset(); + + connect(dialog, &QDialog::accepted, this, &LocalVariableTreeView::reset); + + dialog->open(); } // ***************************************************************************** @@ -1256,8 +1262,10 @@ void ParameterVariableTreeView::onNewButtonPressed() { NewParameterVariableDialog* dialog = new NewParameterVariableDialog(cpu(), this); dialog->setAttribute(Qt::WA_DeleteOnClose); - if (dialog->exec() == QDialog::Accepted) - reset(); + + connect(dialog, &QDialog::accepted, this, &ParameterVariableTreeView::reset); + + dialog->open(); } static bool testName(const QString& name, const QString& filter)