mirror of
https://gitlab.com/Theopse/fbi-i18n-zh.git
synced 2025-04-26 03:16:36 +08:00
Ensure mutex is released.
This commit is contained in:
parent
0c41459643
commit
2aed62c51f
@ -25,9 +25,9 @@ void cleanup() {
|
|||||||
soc_buffer = NULL;
|
soc_buffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
amExit();
|
||||||
ptmuExit();
|
ptmuExit();
|
||||||
acExit();
|
acExit();
|
||||||
amExit();
|
|
||||||
cfguExit();
|
cfguExit();
|
||||||
romfsExit();
|
romfsExit();
|
||||||
gfxExit();
|
gfxExit();
|
||||||
@ -49,7 +49,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
aptCloseSession();
|
aptCloseSession();
|
||||||
|
|
||||||
if(R_FAILED(setCpuTimeRes)) {
|
if(R_FAILED(setCpuTimeRes)) {
|
||||||
util_panic("Failed to set syscore CPU time: %08lX", setCpuTimeRes);
|
util_panic("Failed to set syscore CPU time limit: %08lX", setCpuTimeRes);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,12 +71,8 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
mainmenu_open();
|
mainmenu_open();
|
||||||
|
|
||||||
while(aptMainLoop()) {
|
while(aptMainLoop() && ui_top() != NULL) {
|
||||||
ui_update();
|
ui_update();
|
||||||
if(ui_peek() == NULL) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ui_draw();
|
ui_draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ static void mainmenu_update(ui_view* view, void* data, list_item** items, u32**
|
|||||||
if(hidKeysDown() & KEY_START) {
|
if(hidKeysDown() & KEY_START) {
|
||||||
ui_pop();
|
ui_pop();
|
||||||
list_destroy(view);
|
list_destroy(view);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,26 +9,20 @@
|
|||||||
static void action_launch_title_update(ui_view* view, void* data, float* progress, char* text) {
|
static void action_launch_title_update(ui_view* view, void* data, float* progress, char* text) {
|
||||||
title_info* info = (title_info*) data;
|
title_info* info = (title_info*) data;
|
||||||
|
|
||||||
u8 buf0[0x300];
|
|
||||||
u8 buf1[0x20];
|
|
||||||
|
|
||||||
Result res = 0;
|
Result res = 0;
|
||||||
|
|
||||||
aptOpenSession();
|
aptOpenSession();
|
||||||
|
|
||||||
if(R_SUCCEEDED(res = APT_PrepareToDoAppJump(0, info->titleId, info->mediaType))) {
|
if(R_SUCCEEDED(res = APT_PrepareToDoAppJump(0, info->titleId, info->mediaType))) {
|
||||||
|
u8 buf0[0x300];
|
||||||
|
u8 buf1[0x20];
|
||||||
|
|
||||||
res = APT_DoAppJump(0x300, 0x20, buf0, buf1);
|
res = APT_DoAppJump(0x300, 0x20, buf0, buf1);
|
||||||
}
|
}
|
||||||
|
|
||||||
aptCloseSession();
|
aptCloseSession();
|
||||||
|
|
||||||
info_destroy(view);
|
if(R_FAILED(res)) {
|
||||||
|
|
||||||
if(R_SUCCEEDED(res)) {
|
|
||||||
while(ui_peek() != NULL) {
|
|
||||||
ui_pop();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ui_pop();
|
ui_pop();
|
||||||
info_destroy(view);
|
info_destroy(view);
|
||||||
|
|
||||||
|
@ -28,6 +28,19 @@ void ui_exit() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui_view* ui_top() {
|
||||||
|
svcWaitSynchronization(ui_stack_mutex, U64_MAX);
|
||||||
|
|
||||||
|
ui_view* ui = NULL;
|
||||||
|
if(ui_stack_top >= 0) {
|
||||||
|
ui = ui_stack[ui_stack_top];
|
||||||
|
}
|
||||||
|
|
||||||
|
svcReleaseMutex(ui_stack_mutex);
|
||||||
|
|
||||||
|
return ui;
|
||||||
|
}
|
||||||
|
|
||||||
bool ui_push(ui_view* view) {
|
bool ui_push(ui_view* view) {
|
||||||
if(view == NULL) {
|
if(view == NULL) {
|
||||||
return false;
|
return false;
|
||||||
@ -35,50 +48,30 @@ bool ui_push(ui_view* view) {
|
|||||||
|
|
||||||
svcWaitSynchronization(ui_stack_mutex, U64_MAX);
|
svcWaitSynchronization(ui_stack_mutex, U64_MAX);
|
||||||
|
|
||||||
if(ui_stack_top >= MAX_UI_VIEWS - 1) {
|
bool space = ui_stack_top < MAX_UI_VIEWS - 1;
|
||||||
return false;
|
if(space) {
|
||||||
}
|
|
||||||
|
|
||||||
ui_stack[++ui_stack_top] = view;
|
ui_stack[++ui_stack_top] = view;
|
||||||
|
}
|
||||||
|
|
||||||
svcReleaseMutex(ui_stack_mutex);
|
svcReleaseMutex(ui_stack_mutex);
|
||||||
|
|
||||||
return true;
|
return space;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_view* ui_peek() {
|
void ui_pop() {
|
||||||
svcWaitSynchronization(ui_stack_mutex, U64_MAX);
|
svcWaitSynchronization(ui_stack_mutex, U64_MAX);
|
||||||
|
|
||||||
if(ui_stack_top == -1) {
|
if(ui_stack_top >= 0) {
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ui_view* ui = ui_stack[ui_stack_top];
|
|
||||||
|
|
||||||
svcReleaseMutex(ui_stack_mutex);
|
|
||||||
|
|
||||||
return ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
ui_view* ui_pop() {
|
|
||||||
svcWaitSynchronization(ui_stack_mutex, U64_MAX);
|
|
||||||
|
|
||||||
if(ui_stack_top == -1) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ui_view* view = ui_stack[ui_stack_top];
|
|
||||||
ui_stack[ui_stack_top--] = NULL;
|
ui_stack[ui_stack_top--] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
svcReleaseMutex(ui_stack_mutex);
|
svcReleaseMutex(ui_stack_mutex);
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_update() {
|
void ui_update() {
|
||||||
hidScanInput();
|
hidScanInput();
|
||||||
|
|
||||||
ui_view* ui = ui_peek();
|
ui_view* ui = ui_top();
|
||||||
if(ui != NULL && ui->update != NULL) {
|
if(ui != NULL && ui->update != NULL) {
|
||||||
u32 bottomScreenTopBarHeight = 0;
|
u32 bottomScreenTopBarHeight = 0;
|
||||||
screen_get_texture_size(NULL, &bottomScreenTopBarHeight, TEXTURE_BOTTOM_SCREEN_TOP_BAR);
|
screen_get_texture_size(NULL, &bottomScreenTopBarHeight, TEXTURE_BOTTOM_SCREEN_TOP_BAR);
|
||||||
@ -240,7 +233,7 @@ static void ui_draw_bottom(ui_view* ui) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ui_draw() {
|
void ui_draw() {
|
||||||
ui_view* ui = ui_peek();
|
ui_view* ui = ui_top();
|
||||||
if(ui != NULL) {
|
if(ui != NULL) {
|
||||||
screen_begin_frame();
|
screen_begin_frame();
|
||||||
ui_draw_top(ui);
|
ui_draw_top(ui);
|
||||||
|
@ -14,9 +14,9 @@ typedef struct ui_view_s {
|
|||||||
void ui_init();
|
void ui_init();
|
||||||
void ui_exit();
|
void ui_exit();
|
||||||
|
|
||||||
|
ui_view* ui_top();
|
||||||
bool ui_push(ui_view* view);
|
bool ui_push(ui_view* view);
|
||||||
ui_view* ui_peek();
|
void ui_pop();
|
||||||
ui_view* ui_pop();
|
|
||||||
void ui_update();
|
void ui_update();
|
||||||
void ui_draw();
|
void ui_draw();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user