diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index 0875906f0b..2e863d4c26 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -1313,27 +1313,8 @@ static void rcheevos_fetch_badges(void) rcheevos_client_fetch_badges(rcheevos_fetch_badges_callback, NULL); } -static void rcheevos_start_session(void) +static void rcheevos_start_session_async(retro_task_t* task) { - if (rcheevos_load_aborted()) - { - CHEEVOS_LOG(RCHEEVOS_TAG "Load aborted before starting session\n"); - return; - } - - if ( rcheevos_locals.game.achievement_count == 0 - && rcheevos_locals.game.leaderboard_count == 0) - { - if (!rcheevos_locals.runtime.richpresence) - { - /* nothing for the runtime to process, - * disable hardcore and bail */ - rcheevos_show_game_placard(); - rcheevos_pause_hardcore(); - return; - } - } - rcheevos_begin_load_state(RCHEEVOS_LOAD_STATE_STARTING_SESSION); /* activate the achievements and leaderboards @@ -1378,10 +1359,41 @@ static void rcheevos_start_session(void) rcheevos_show_game_placard(); + task_set_finished(task, true); + if (rcheevos_end_load_state() == 0) rcheevos_fetch_badges(); } +static void rcheevos_start_session(void) +{ + retro_task_t* task; + + if (rcheevos_load_aborted()) + { + CHEEVOS_LOG(RCHEEVOS_TAG "Load aborted before starting session\n"); + return; + } + + if (rcheevos_locals.game.achievement_count == 0 + && rcheevos_locals.game.leaderboard_count == 0) + { + if (!rcheevos_locals.runtime.richpresence) + { + /* nothing for the runtime to process, + * disable hardcore and bail */ + rcheevos_show_game_placard(); + rcheevos_pause_hardcore(); + return; + } + } + + /* this is called on the primary thread. use a task to do the initialization on a background thread */ + task = task_init(); + task->handler = rcheevos_start_session_async; + task_queue_push(task); +} + static void rcheevos_initialize_runtime_callback(void* userdata) { rcheevos_start_session(); diff --git a/cheevos/cheevos_client.c b/cheevos/cheevos_client.c index 9ed2eb209e..f9fb7ea0a3 100644 --- a/cheevos/cheevos_client.c +++ b/cheevos/cheevos_client.c @@ -442,9 +442,7 @@ static void rcheevos_async_http_task_callback( * response is properly formatted or will encounter a parse failure * before reading past the end of the data */ if (request->handler) - { request->handler(request, data, buffer, sizeof(buffer)); - } } if (!buffer[0]) diff --git a/gfx/widgets/gfx_widget_achievement_popup.c b/gfx/widgets/gfx_widget_achievement_popup.c index 537b5859c8..160f2cb479 100644 --- a/gfx/widgets/gfx_widget_achievement_popup.c +++ b/gfx/widgets/gfx_widget_achievement_popup.c @@ -297,7 +297,8 @@ static void gfx_widget_achievement_popup_next(void* userdata) if (state->queue_read_index >= 0) { - gfx_widget_achievement_popup_free_current(state); + if (state->queue[state->queue_read_index].title) + gfx_widget_achievement_popup_free_current(state); /* start the next popup (if present) */ if (state->queue[state->queue_read_index].title)