Skip to content

Commit 56cc8a2

Browse files
committed
Debugger: Replace calls to QDialog::exec with QDialog::open
1 parent 1fbe8c9 commit 56cc8a2

File tree

3 files changed

+50
-30
lines changed

3 files changed

+50
-30
lines changed

pcsx2-qt/Debugger/DisassemblyView.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,16 @@ void DisassemblyView::contextGoToAddress()
265265
void DisassemblyView::contextAddFunction()
266266
{
267267
NewFunctionDialog* dialog = new NewFunctionDialog(cpu(), this);
268-
dialog->setAttribute(Qt::WA_DeleteOnClose);
269268
dialog->setName(QString("func_%1").arg(m_selectedAddressStart, 8, 16, QChar('0')));
270269
dialog->setAddress(m_selectedAddressStart);
270+
dialog->setAttribute(Qt::WA_DeleteOnClose);
271+
271272
if (m_selectedAddressEnd != m_selectedAddressStart)
272273
dialog->setCustomSize(m_selectedAddressEnd - m_selectedAddressStart + 4);
273-
if (dialog->exec() == QDialog::Accepted)
274-
update();
274+
275+
connect(dialog, &QDialog::accepted, this, [this]() { update(); });
276+
277+
dialog->open();
275278
}
276279

277280
void DisassemblyView::contextCopyFunctionName()

pcsx2-qt/Debugger/Docking/DockManager.cpp

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -518,17 +518,19 @@ void DockManager::newLayoutClicked()
518518
if (m_menu_bar)
519519
m_menu_bar->onCurrentLayoutChanged(m_current_layout);
520520

521-
auto name_validator = [this](const QString& name) {
521+
const auto name_validator = [this](const QString& name) {
522522
return !hasNameConflict(name, DockLayout::INVALID_INDEX);
523523
};
524524

525-
bool can_clone_current_layout = m_current_layout != DockLayout::INVALID_INDEX;
525+
const bool can_clone_current_layout = m_current_layout != DockLayout::INVALID_INDEX;
526526

527-
QPointer<LayoutEditorDialog> dialog = new LayoutEditorDialog(
528-
name_validator, can_clone_current_layout, g_debugger_window);
527+
LayoutEditorDialog* dialog = new LayoutEditorDialog(name_validator, can_clone_current_layout, g_debugger_window);
528+
dialog->setAttribute(Qt::WA_DeleteOnClose);
529+
530+
connect(dialog, &QDialog::accepted, this, [this, dialog, name_validator]() {
531+
if (!name_validator(dialog->name()))
532+
return;
529533

530-
if (dialog->exec() == QDialog::Accepted && name_validator(dialog->name()))
531-
{
532534
DockLayout::Index new_layout = DockLayout::INVALID_INDEX;
533535

534536
const auto [mode, index] = dialog->initialState();
@@ -565,9 +567,9 @@ void DockManager::newLayoutClicked()
565567
updateLayoutSwitcher();
566568
switchToLayout(new_layout);
567569
}
568-
}
570+
});
569571

570-
delete dialog.get();
572+
dialog->open();
571573
}
572574

573575
void DockManager::openLayoutSwitcherContextMenu(const QPoint& pos, QTabBar* layout_switcher)
@@ -605,26 +607,33 @@ void DockManager::editLayoutClicked(DockLayout::Index layout_index)
605607
if (layout_index >= m_layouts.size())
606608
return;
607609

608-
DockLayout& layout = m_layouts[layout_index];
610+
const DockLayout& layout = m_layouts[layout_index];
609611

610-
auto name_validator = [this, layout_index](const QString& name) {
612+
const auto name_validator = [this, layout_index](const QString& name) {
611613
return !hasNameConflict(name, layout_index);
612614
};
613615

614-
QPointer<LayoutEditorDialog> dialog = new LayoutEditorDialog(
615-
layout.name(), layout.cpu(), name_validator, g_debugger_window);
616+
LayoutEditorDialog* dialog = new LayoutEditorDialog(layout.name(), layout.cpu(), name_validator, g_debugger_window);
617+
dialog->setAttribute(Qt::WA_DeleteOnClose);
616618

617-
if (dialog->exec() != QDialog::Accepted || !name_validator(dialog->name()))
618-
return;
619+
connect(dialog, &QDialog::accepted, this, [this, layout_index, dialog, name_validator]() {
620+
if (layout_index >= m_layouts.size())
621+
return;
619622

620-
layout.setName(dialog->name());
621-
layout.setCpu(dialog->cpu());
623+
DockLayout& layout = m_layouts[layout_index];
622624

623-
layout.save(layout_index);
625+
if (!name_validator(dialog->name()))
626+
return;
624627

625-
delete dialog.get();
628+
layout.setName(dialog->name());
629+
layout.setCpu(dialog->cpu());
626630

627-
updateLayoutSwitcher();
631+
layout.save(layout_index);
632+
633+
updateLayoutSwitcher();
634+
});
635+
636+
dialog->open();
628637
}
629638

630639
void DockManager::resetLayoutClicked(DockLayout::Index layout_index)

pcsx2-qt/Debugger/SymbolTree/SymbolTreeViews.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -857,8 +857,10 @@ void FunctionTreeView::onNewButtonPressed()
857857
{
858858
NewFunctionDialog* dialog = new NewFunctionDialog(cpu(), this);
859859
dialog->setAttribute(Qt::WA_DeleteOnClose);
860-
if (dialog->exec() == QDialog::Accepted)
861-
reset();
860+
861+
connect(dialog, &QDialog::accepted, this, &FunctionTreeView::reset);
862+
863+
dialog->open();
862864
}
863865

864866
// *****************************************************************************
@@ -1000,8 +1002,10 @@ void GlobalVariableTreeView::onNewButtonPressed()
10001002
{
10011003
NewGlobalVariableDialog* dialog = new NewGlobalVariableDialog(cpu(), this);
10021004
dialog->setAttribute(Qt::WA_DeleteOnClose);
1003-
if (dialog->exec() == QDialog::Accepted)
1004-
reset();
1005+
1006+
connect(dialog, &QDialog::accepted, this, &GlobalVariableTreeView::reset);
1007+
1008+
dialog->open();
10051009
}
10061010

10071011
// *****************************************************************************
@@ -1129,8 +1133,10 @@ void LocalVariableTreeView::onNewButtonPressed()
11291133
{
11301134
NewLocalVariableDialog* dialog = new NewLocalVariableDialog(cpu(), this);
11311135
dialog->setAttribute(Qt::WA_DeleteOnClose);
1132-
if (dialog->exec() == QDialog::Accepted)
1133-
reset();
1136+
1137+
connect(dialog, &QDialog::accepted, this, &LocalVariableTreeView::reset);
1138+
1139+
dialog->open();
11341140
}
11351141

11361142
// *****************************************************************************
@@ -1256,8 +1262,10 @@ void ParameterVariableTreeView::onNewButtonPressed()
12561262
{
12571263
NewParameterVariableDialog* dialog = new NewParameterVariableDialog(cpu(), this);
12581264
dialog->setAttribute(Qt::WA_DeleteOnClose);
1259-
if (dialog->exec() == QDialog::Accepted)
1260-
reset();
1265+
1266+
connect(dialog, &QDialog::accepted, this, &ParameterVariableTreeView::reset);
1267+
1268+
dialog->open();
12611269
}
12621270

12631271
static bool testName(const QString& name, const QString& filter)

0 commit comments

Comments
 (0)