shithub: cstory

Download patch

ref: e732534e919b6a30bd562c0ab3b71899bee051c5
parent: c50155b1b0f2517efbe62c3f9a64c1d73e68a4f2
author: Clownacy <Clownacy@users.noreply.github.com>
date: Wed Oct 14 14:40:37 EDT 2020

3DS - Fix hang on shutdown

--- a/src/Backends/Platform/3DS.cpp
+++ b/src/Backends/Platform/3DS.cpp
@@ -91,7 +91,7 @@
 {
 	(void)active;
 
-	return aptMainLoop();
+	return true;
 }
 
 void Backend_GetKeyboardState(bool *keyboard_state)
--- a/src/Draw.cpp
+++ b/src/Draw.cpp
@@ -6,6 +6,10 @@
 #include <string.h>
 #include <string>
 
+#ifdef _3DS
+ #include <3ds.h>
+#endif
+
 #include "WindowsWrapper.h"
 
 #include "Backends/Misc.h"
@@ -75,6 +79,14 @@
 		timePrev += 20;
 
 	RenderBackend_DrawScreen();
+
+#ifdef _3DS
+	// This would go in Backend_SystemTask, but that causes a hang
+	// because of a race condition: aptMainLoop cannot be called
+	// between C3D_FrameBegin and C3D_FrameEnd
+	if (!aptMainLoop())
+		return false;
+#endif
 
 	if (RestoreSurfaces())
 	{