From fe0ae83c40fab1a01887fdb142b5a8acb0b072b1 Mon Sep 17 00:00:00 2001 From: rogerman Date: Tue, 2 Jul 2024 00:16:46 -0700 Subject: [PATCH] Cocoa Port: Fix a longstanding, yet rare, crash that may occur when quitting the app. --- desmume/src/frontend/cocoa/cocoa_GPU.mm | 2 -- desmume/src/frontend/cocoa/cocoa_core.mm | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/desmume/src/frontend/cocoa/cocoa_GPU.mm b/desmume/src/frontend/cocoa/cocoa_GPU.mm index c9437cf5a..156a2da11 100644 --- a/desmume/src/frontend/cocoa/cocoa_GPU.mm +++ b/desmume/src/frontend/cocoa/cocoa_GPU.mm @@ -193,8 +193,6 @@ - (id)init - (void)dealloc { - DestroyOpenGLRenderer(); - delete fetchObject; delete gpuEvent; diff --git a/desmume/src/frontend/cocoa/cocoa_core.mm b/desmume/src/frontend/cocoa/cocoa_core.mm index e4e7f6e43..4903cdb1a 100644 --- a/desmume/src/frontend/cocoa/cocoa_core.mm +++ b/desmume/src/frontend/cocoa/cocoa_core.mm @@ -226,6 +226,10 @@ - (void)dealloc delete execControl; NDS_DeInit(); + // We must call DestroyOpenGLRenderer() after NDS_Init() because we need to wait for + // the OpenGL renderer to finish before we destroy its associated context. + DestroyOpenGLRenderer(); + [super dealloc]; }