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 std::string g_selectedCheatKey;
inline std::vector<std::string> g_selectedCheatCodes;
inline volatile bool g_isLoadingTitles = false;
#endif

View file

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

View file

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