Debugger: Replace calls to QDialog::exec with QDialog::open

This commit is contained in:
chaoticgd 2025-11-24 17:41:28 +00:00
parent a1b8799bd6
commit 13b0f4a24c
No known key found for this signature in database
GPG Key ID: FFFC3F38B3A0E6D8
3 changed files with 50 additions and 30 deletions

View File

@ -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()

View File

@ -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<LayoutEditorDialog> 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<LayoutEditorDialog> 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)

View File

@ -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)