Make it impossible to exit before the title thread is finished

This commit is contained in:
BernardoGiordano 2019-09-06 22:03:38 +02:00
parent 53235c622c
commit 718fc2cdee
3 changed files with 11 additions and 5 deletions

View file

@ -38,5 +38,6 @@ inline bool g_bottomScrollEnabled = false;
inline float g_timer = 0; inline float g_timer = 0;
inline std::string g_selectedCheatKey; inline std::string g_selectedCheatKey;
inline std::vector<std::string> g_selectedCheatCodes; inline std::vector<std::string> g_selectedCheatCodes;
inline volatile bool g_isLoadingTitles = false;
#endif #endif

View file

@ -40,11 +40,17 @@ int main()
Threads::create((ThreadFunc)Threads::titles); Threads::create((ThreadFunc)Threads::titles);
ATEXIT(Threads::destroy); ATEXIT(Threads::destroy);
while (aptMainLoop() && !(hidKeysDown() & KEY_START)) { while (aptMainLoop()) {
touchPosition touch; touchPosition touch;
hidScanInput(); hidScanInput();
hidTouchRead(&touch); hidTouchRead(&touch);
if (hidKeysDown() & KEY_START) {
if (!g_isLoadingTitles) {
break;
}
}
if (Configuration::getInstance().shouldScanCard()) { if (Configuration::getInstance().shouldScanCard()) {
updateCard(); updateCard();
} }

View file

@ -29,7 +29,6 @@
static std::vector<Thread> threads; static std::vector<Thread> threads;
static bool forceRefresh = false; static bool forceRefresh = false;
static volatile bool isLoadingTitles = false;
void Threads::create(ThreadFunc entrypoint) void Threads::create(ThreadFunc entrypoint)
{ {
@ -50,12 +49,12 @@ void Threads::destroy(void)
void Threads::titles(void) void Threads::titles(void)
{ {
// don't load titles while they're loading // don't load titles while they're loading
if (isLoadingTitles) { if (g_isLoadingTitles) {
return; return;
} }
isLoadingTitles = true; g_isLoadingTitles = true;
loadTitles(forceRefresh); loadTitles(forceRefresh);
forceRefresh = true; forceRefresh = true;
isLoadingTitles = false; g_isLoadingTitles = false;
} }