mirror of https://github.com/PCSX2/pcsx2.git
Debugger: Unbind the BP UpdateHandler on destructing DebuggerWindow
Prevents an use-after-free on the DebuggerWindow object
This commit is contained in:
parent
c3c602b5a4
commit
5e1009b4fb
|
@ -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.
|
||||
|
|
|
@ -76,7 +76,11 @@ public slots:
|
|||
{
|
||||
if (!QtHost::IsOnUIThread())
|
||||
{
|
||||
QtHost::RunOnUIThread(CBreakPoints::GetUpdateHandler());
|
||||
const auto& updateHandler = CBreakPoints::GetUpdateHandler();
|
||||
if (updateHandler)
|
||||
{
|
||||
QtHost::RunOnUIThread(updateHandler);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<void()> f) {cb_bpUpdated_ = f; };
|
||||
static std::function<void()> GetUpdateHandler() { return cb_bpUpdated_; };
|
||||
static void SetUpdateHandler(std::function<void()> f) {cb_bpUpdated_ = std::move(f); };
|
||||
static const std::function<void()>& GetUpdateHandler() { return cb_bpUpdated_; };
|
||||
|
||||
private:
|
||||
static size_t FindBreakpoint(BreakPointCpu cpu, u32 addr, bool matchTemp = false, bool temp = false);
|
||||
|
|
Loading…
Reference in New Issue