From d480f95d7936066a1219d171cf5be70d77db8301 Mon Sep 17 00:00:00 2001 From: rogerman Date: Fri, 12 Jul 2024 12:00:49 -0700 Subject: [PATCH] Cocoa Port: Fix yet another crash-on-exit bug that could happen when running on an older system. --- desmume/src/GPU.cpp | 7 +++++++ desmume/src/frontend/cocoa/cocoa_GPU.mm | 2 ++ 2 files changed, 9 insertions(+) diff --git a/desmume/src/GPU.cpp b/desmume/src/GPU.cpp index ae4d29ca9..c3a24bd07 100644 --- a/desmume/src/GPU.cpp +++ b/desmume/src/GPU.cpp @@ -4763,6 +4763,13 @@ void GPUSubsystem::_UpdateFPSRender3D() void GPUSubsystem::SetEventHandler(GPUEventHandler *eventHandler) { + if ( (eventHandler == NULL) && (this->_event != this->_defaultEventHandler) ) + { + this->ForceFrameStop(); + this->_event = this->_defaultEventHandler; + return; + } + this->_event = eventHandler; } diff --git a/desmume/src/frontend/cocoa/cocoa_GPU.mm b/desmume/src/frontend/cocoa/cocoa_GPU.mm index 156a2da11..3b29db7c9 100644 --- a/desmume/src/frontend/cocoa/cocoa_GPU.mm +++ b/desmume/src/frontend/cocoa/cocoa_GPU.mm @@ -193,6 +193,8 @@ - (id)init - (void)dealloc { + GPU->SetEventHandler(NULL); // Unassigned our event handler before we delete it. + delete fetchObject; delete gpuEvent;