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)