From 0645b4d5792111cc992b85cda6694c95ab43408f Mon Sep 17 00:00:00 2001 From: mitaclaw <140017135+mitaclaw@users.noreply.github.com> Date: Tue, 5 Mar 2024 14:02:45 -0800 Subject: BranchWatchDialog: Fix Misc. Errata Window icon was missing from QDialog lacking a parent. Giving the QDialog a parent revealed I had failed to make it properly non-modal, necessitating further changes. Settings save less often, now only upon destruction. Construction of BranchWatchDialog is now deferred. --- .../Core/DolphinQt/Debugger/BranchWatchDialog.cpp | 30 ++++++++++++---------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'Source/Core/DolphinQt/Debugger/BranchWatchDialog.cpp') diff --git a/Source/Core/DolphinQt/Debugger/BranchWatchDialog.cpp b/Source/Core/DolphinQt/Debugger/BranchWatchDialog.cpp index f5e6a5acc3..f45da30d20 100644 --- a/Source/Core/DolphinQt/Debugger/BranchWatchDialog.cpp +++ b/Source/Core/DolphinQt/Debugger/BranchWatchDialog.cpp @@ -504,15 +504,9 @@ BranchWatchDialog::BranchWatchDialog(Core::System& system, Core::BranchWatch& br restoreGeometry(settings.value(QStringLiteral("branchwatchdialog/geometry")).toByteArray()); } -void BranchWatchDialog::done(int r) +BranchWatchDialog::~BranchWatchDialog() { - if (m_timer->isActive()) - m_timer->stop(); - auto& settings = Settings::GetQSettings(); - settings.setValue(QStringLiteral("branchwatchdialog/geometry"), saveGeometry()); - settings.setValue(QStringLiteral("branchwatchdialog/tableheader/state"), - m_table_view->horizontalHeader()->saveState()); - QDialog::done(r); + SaveSettings(); } static constexpr int BRANCH_WATCH_TOOL_TIMER_DELAY_MS = 100; @@ -523,18 +517,18 @@ static bool TimerCondition(const Core::BranchWatch& branch_watch, Core::State st return branch_watch.GetRecordingActive() && state > Core::State::Paused; } -int BranchWatchDialog::exec() +void BranchWatchDialog::hideEvent(QHideEvent* event) { - if (TimerCondition(m_branch_watch, Core::GetState())) - m_timer->start(BRANCH_WATCH_TOOL_TIMER_DELAY_MS); - return QDialog::exec(); + if (m_timer->isActive()) + m_timer->stop(); + QDialog::hideEvent(event); } -void BranchWatchDialog::open() +void BranchWatchDialog::showEvent(QShowEvent* event) { if (TimerCondition(m_branch_watch, Core::GetState())) m_timer->start(BRANCH_WATCH_TOOL_TIMER_DELAY_MS); - QDialog::open(); + QDialog::showEvent(event); } void BranchWatchDialog::OnStartPause(bool checked) @@ -927,6 +921,14 @@ void BranchWatchDialog::OnTableCopyAddress(QModelIndexList index_list) QApplication::clipboard()->setText(text); } +void BranchWatchDialog::SaveSettings() +{ + auto& settings = Settings::GetQSettings(); + settings.setValue(QStringLiteral("branchwatchdialog/geometry"), saveGeometry()); + settings.setValue(QStringLiteral("branchwatchdialog/tableheader/state"), + m_table_view->horizontalHeader()->saveState()); +} + void BranchWatchDialog::Update() { if (m_branch_watch.GetRecordingPhase() == Core::BranchWatch::Phase::Blacklist) -- cgit v1.2.3