fix multiple crashes

on exit:
- bad timing when the install checks threads run, could crash
- quitting through HOME when a bgm was previewed in the browser
on http get failure:
- the quit flag would be enabled, but the browser wouldn't honour it
This commit is contained in:
LiquidFenrir
2022-06-05 11:49:09 +02:00
parent 4c053bb447
commit 806d0033de
2 changed files with 17 additions and 8 deletions

View File

@@ -109,6 +109,12 @@ static void stop_install_check(void)
{ {
installCheckThreads_arg[i].run_thread = false; installCheckThreads_arg[i].run_thread = false;
} }
for(int i = 0; i < MODE_AMOUNT; i++)
{
threadJoin(installCheckThreads[i], U64_MAX);
threadFree(installCheckThreads[i]);
installCheckThreads[i] = NULL;
}
} }
static void exit_thread(void) static void exit_thread(void)
@@ -121,6 +127,7 @@ static void exit_thread(void)
svcWaitSynchronization(update_icons_mutex, U64_MAX); svcWaitSynchronization(update_icons_mutex, U64_MAX);
threadJoin(iconLoadingThread, U64_MAX); threadJoin(iconLoadingThread, U64_MAX);
threadFree(iconLoadingThread); threadFree(iconLoadingThread);
iconLoadingThread = NULL;
} }
} }
@@ -138,6 +145,7 @@ static void free_icons(Entry_List_s * list)
free(list->icons[i]); free(list->icons[i]);
} }
free(list->icons); free(list->icons);
list->icons = NULL;
} }
void free_lists(void) void free_lists(void)
@@ -230,7 +238,7 @@ static void load_lists(Entry_List_s * lists)
if(install_check_function != NULL) if(install_check_function != NULL)
{ {
installCheckThreads[i] = threadCreate(install_check_function, current_arg, __stacksize__, 0x3f, -2, true); installCheckThreads[i] = threadCreate(install_check_function, current_arg, __stacksize__, 0x3f, -2, false);
svcSleepThread(1e8); svcSleepThread(1e8);
} }
} }

View File

@@ -483,7 +483,7 @@ bool themeplaza_browser(EntryMode mode)
bool extra_mode = false; bool extra_mode = false;
while (aptMainLoop()) while (aptMainLoop() && !quit)
{ {
if (current_list->entries == NULL) if (current_list->entries == NULL)
break; break;
@@ -511,12 +511,6 @@ bool themeplaza_browser(EntryMode mode)
exit: exit:
quit = true; quit = true;
downloaded = false; downloaded = false;
if (audio)
{
audio->stop = true;
svcWaitSynchronization(audio->finished, U64_MAX);
audio = NULL;
}
break; break;
} }
@@ -725,6 +719,13 @@ bool themeplaza_browser(EntryMode mode)
} }
} }
if (audio)
{
audio->stop = true;
svcWaitSynchronization(audio->finished, U64_MAX);
audio = NULL;
}
free_preview(preview); free_preview(preview);
free_icons(current_list); free_icons(current_list);