diff --git a/src/ase.c b/src/ase.c index fbac5e9e..22b113d3 100644 --- a/src/ase.c +++ b/src/ase.c @@ -799,10 +799,9 @@ struct ase_decode_image_result ase_decode_image(struct arena *arena, struct buff /* ASSERT all data was read */ ASSERT(br_bytes_left(&br) == 0); -abort: + abort: scratch_end(scratch); - return res; } diff --git a/src/json.c b/src/json.c index c501cb83..e51b46a0 100644 --- a/src/json.c +++ b/src/json.c @@ -817,10 +817,12 @@ INTERNAL void parse(struct arena *arena, struct parser *p) } } -abort: - scratch_end(scratch); + abort: + p->at = at; p->root = root; + + scratch_end(scratch); } /* ========================== * diff --git a/src/settings.c b/src/settings.c index a6345cfa..958895e1 100644 --- a/src/settings.c +++ b/src/settings.c @@ -137,7 +137,8 @@ struct sys_window_settings *settings_deserialize(struct arena *arena, struct buf if (!found_width) { error = STR("Missing \"width\""); goto abort; } if (!found_height) { error = STR("Missing \"height\""); goto abort; } -abort: + abort: + if (error_out && (error.len > 0 || json_error.msg.len > 0)) { if (json_error.msg.len > 0) { *error_out = string_format(arena, diff --git a/src/sheet.c b/src/sheet.c index 8b880a4b..50d2a0b8 100644 --- a/src/sheet.c +++ b/src/sheet.c @@ -196,7 +196,8 @@ INTERNAL WORK_TASK_FUNC_DEF(sheet_load_asset_task, vparams) goto abort; } -abort: + abort: + if (!success) { logf_error("Error loading sheet \"%F\": %F", FMT_STR(path), FMT_STR(error_msg)); diff --git a/src/sound.c b/src/sound.c index f97624fd..80a0eaa8 100644 --- a/src/sound.c +++ b/src/sound.c @@ -147,7 +147,8 @@ INTERNAL WORK_TASK_FUNC_DEF(sound_load_asset_task, vparams) goto abort; } -abort: + abort: + if (!success) { logf_error("Error loading sound \"%F\": %F", FMT_STR(path), FMT_STR(error_msg)); diff --git a/src/sys_win32.c b/src/sys_win32.c index 2f2da9b3..9e9b29ac 100644 --- a/src/sys_win32.c +++ b/src/sys_win32.c @@ -1861,7 +1861,7 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance, if (L.thread_tls_index == TLS_OUT_OF_INDEXES) { /* TODO: GetLastError */ error_msg = L"Platform initialization error: TLS_OUT_OF_INDEXES"; - goto error; + goto abort; } /* Initialize main thread context. @@ -1901,7 +1901,7 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance, if (!RegisterClassExW(wc)) { /* TODO: GetLastError */ error_msg = L"Failed to register window class"; - goto error; + goto abort; } } @@ -1916,21 +1916,22 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance, if (!RegisterRawInputDevices(&rid, 1, sizeof(rid))) { /* TODO: GetLastError */ error_msg = L"Failed to register raw input device"; - goto error; + goto abort; } } -error: - if (error_msg) { - MessageBoxExW(NULL, error_msg, L"Fatal initialization error", MB_ICONSTOP, 0); - ASSERT(false); - return 1; - } - /* Create app thread & wait for return */ struct sys_thread app_thread = sys_thread_init(&app_thread_entry_point, NULL, STR("[P9] App thread")); sys_thread_join(&app_thread); + abort: + + if (error_msg) { + MessageBoxExW(NULL, error_msg, L"Fatal initialization error", MB_ICONSTOP, 0); + ASSERT(false); + return 1; + } + win32_tls_release(&main_thread_tls); /* Uninitialize COM */ diff --git a/src/texture.c b/src/texture.c index ba96da21..63f5ea2c 100644 --- a/src/texture.c +++ b/src/texture.c @@ -199,7 +199,8 @@ INTERNAL WORK_TASK_FUNC_DEF(texture_load_asset_task, vparams) goto abort; } -abort: + abort: + if (!success) { logf_error("Error loading texture \"%F\": %F", FMT_STR(path), FMT_STR(error_msg));