From 161aa99fa0bcce8b64577e8d8a2b422bff9e7a14 Mon Sep 17 00:00:00 2001 From: John Galvin <96908304+Johnnyg63@users.noreply.github.com> Date: Thu, 1 Oct 2026 20:10:52 +0100 Subject: [PATCH] 325-fix-the-hang-when-onusercreate-return-false-on-macos --- dev/src/host_apple_macos.cpp | 6 +++++- olcPixelGameEngine3.h | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/dev/src/host_apple_macos.cpp b/dev/src/host_apple_macos.cpp index a79b86a..eec3830 100644 --- a/dev/src/host_apple_macos.cpp +++ b/dev/src/host_apple_macos.cpp @@ -310,7 +310,8 @@ namespace olc::host { if (!this->OnSystemThreadStart()) { // PGE->OnContextStart() failed, or user aborted OnUserCreate() - return; + StopSystem(); + } // Main system loop @@ -346,6 +347,9 @@ namespace olc::host { bool Host_Apple_MacOS::StopSystem() { + // Clear any pending tasks/messages on the main thread + bSkipFrame = ExecutePendingMainThreadTasks(); + dispatch_sync(dispatch_get_main_queue(), ^{ // clean up and close application if (pMacOSOpenGLRenderer) diff --git a/olcPixelGameEngine3.h b/olcPixelGameEngine3.h index 3725ed0..a54466f 100644 --- a/olcPixelGameEngine3.h +++ b/olcPixelGameEngine3.h @@ -11822,7 +11822,8 @@ namespace olc::host { if (!this->OnSystemThreadStart()) { // PGE->OnContextStart() failed, or user aborted OnUserCreate() - return; + StopSystem(); + } // Main system loop @@ -11858,6 +11859,9 @@ namespace olc::host { bool Host_Apple_MacOS::StopSystem() { + // Clear any pending tasks/messages on the main thread + bSkipFrame = ExecutePendingMainThreadTasks(); + dispatch_sync(dispatch_get_main_queue(), ^{ // clean up and close application if (pMacOSOpenGLRenderer)