From e732534e919b6a30bd562c0ab3b71899bee051c5 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 14 Oct 2020 18:40:37 +0100 Subject: [PATCH] 3DS - Fix hang on shutdown --- src/Backends/Platform/3DS.cpp | 2 +- src/Draw.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Backends/Platform/3DS.cpp b/src/Backends/Platform/3DS.cpp index a7620ddb..70adab4e 100644 --- a/src/Backends/Platform/3DS.cpp +++ b/src/Backends/Platform/3DS.cpp @@ -91,7 +91,7 @@ bool Backend_SystemTask(bool active) { (void)active; - return aptMainLoop(); + return true; } void Backend_GetKeyboardState(bool *keyboard_state) diff --git a/src/Draw.cpp b/src/Draw.cpp index be3d3f5e..6296f1eb 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -6,6 +6,10 @@ #include #include +#ifdef _3DS + #include <3ds.h> +#endif + #include "WindowsWrapper.h" #include "Backends/Misc.h" @@ -76,6 +80,14 @@ BOOL Flip_SystemTask(void) 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()) { RestoreStripper();