diff --git a/pcsx2-qt/Debugger/CpuWidget.cpp b/pcsx2-qt/Debugger/CpuWidget.cpp index 9d9e1ec8a7..59b777929c 100644 --- a/pcsx2-qt/Debugger/CpuWidget.cpp +++ b/pcsx2-qt/Debugger/CpuWidget.cpp @@ -43,7 +43,7 @@ CpuWidget::CpuWidget(QWidget* parent, DebugInterface& cpu) m_ui.setupUi(this); connect(g_emu_thread, &EmuThread::onVMPaused, this, &CpuWidget::onVMPaused); - connect(g_emu_thread, &EmuThread::onGameChanged, [this](const QString& title) { + connect(g_emu_thread, &EmuThread::onGameChanged, this, [this](const QString& title) { if (title.isEmpty()) return; // Don't overwrite users BPs/Saved Addresses unless they have a clean state. diff --git a/pcsx2-qt/Debugger/CpuWidget.h b/pcsx2-qt/Debugger/CpuWidget.h index 7f09a19eeb..a4ec6e13b4 100644 --- a/pcsx2-qt/Debugger/CpuWidget.h +++ b/pcsx2-qt/Debugger/CpuWidget.h @@ -76,7 +76,11 @@ public slots: { if (!QtHost::IsOnUIThread()) { - QtHost::RunOnUIThread(CBreakPoints::GetUpdateHandler()); + const auto& updateHandler = CBreakPoints::GetUpdateHandler(); + if (updateHandler) + { + QtHost::RunOnUIThread(updateHandler); + } return; } diff --git a/pcsx2-qt/Debugger/DebuggerWindow.cpp b/pcsx2-qt/Debugger/DebuggerWindow.cpp index 9266dec1aa..37af87a45e 100644 --- a/pcsx2-qt/Debugger/DebuggerWindow.cpp +++ b/pcsx2-qt/Debugger/DebuggerWindow.cpp @@ -47,11 +47,12 @@ DebuggerWindow::DebuggerWindow(QWidget* parent) m_ui.cpuTabs->addTab(m_cpuWidget_r3000, "R3000"); CBreakPoints::SetUpdateHandler(std::bind(&DebuggerWindow::onBreakpointsChanged, this)); - - return; } -DebuggerWindow::~DebuggerWindow() = default; +DebuggerWindow::~DebuggerWindow() +{ + CBreakPoints::SetUpdateHandler(nullptr); +} // There is no straightforward way to set the tab text to bold in Qt // Sorry colour blind people, but this is the best we can do for now diff --git a/pcsx2/DebugTools/Breakpoints.h b/pcsx2/DebugTools/Breakpoints.h index b9de23ff24..af11bee072 100644 --- a/pcsx2/DebugTools/Breakpoints.h +++ b/pcsx2/DebugTools/Breakpoints.h @@ -151,8 +151,8 @@ public: static void SetCorePaused(bool b) { corePaused = b; }; // This will have to do until a full fledged debugger host interface is made - static void SetUpdateHandler(std::function f) {cb_bpUpdated_ = f; }; - static std::function GetUpdateHandler() { return cb_bpUpdated_; }; + static void SetUpdateHandler(std::function f) {cb_bpUpdated_ = std::move(f); }; + static const std::function& GetUpdateHandler() { return cb_bpUpdated_; }; private: static size_t FindBreakpoint(BreakPointCpu cpu, u32 addr, bool matchTemp = false, bool temp = false);