From 1affe0bff3c62fbdc6235e061d40d82eecf71785 Mon Sep 17 00:00:00 2001 From: Xie Yi Date: Tue, 11 Jun 2019 14:44:06 +0800 Subject: [PATCH] Fix shutdown because of Discord deinitializer https://github.com/hrydgard/ppsspp/blob/f94beb518504eebadb94dfdc009cf9f4461bc6a4/UI/DiscordIntegration.cpp#L40 Calling exit(0) without NativeShutdown() breaks the assertion. --- ios/ViewController.mm | 3 ++- ios/main.mm | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ios/ViewController.mm b/ios/ViewController.mm index bdcf92e7d53d..ad334f0d8d41 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -213,7 +213,6 @@ - (void)viewDidLoad { time_update(); } - threadStopped = true; ILOG("Emulation thread shutting down\n"); NativeShutdownGraphics(); @@ -221,6 +220,8 @@ - (void)viewDidLoad { // Also ask the main thread to stop, so it doesn't hang waiting for a new frame. ILOG("Emulation thread stopping\n"); graphicsContext->StopThread(); + + threadStopped = true; }); } diff --git a/ios/main.mm b/ios/main.mm index ce1803e023da..e52f3f8bf9f5 100644 --- a/ios/main.mm +++ b/ios/main.mm @@ -61,7 +61,10 @@ bool System_GetPropertyBool(SystemProperty prop) { void System_SendMessage(const char *command, const char *parameter) { if (!strcmp(command, "finish")) { - exit(0); + dispatch_async(dispatch_get_main_queue(), ^{ + [sharedViewController shutdown]; + exit(0); + }); } }