Skip to content

Commit

Permalink
Fix a crash when a game fails to load.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arignir committed Dec 10, 2023
1 parent 760e5a1 commit b2334d9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion include/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ struct app {

/* common/game.c */
void app_game_process_all_notifs(struct app *app);
void app_game_configure(struct app *app, char const *rom_path);
bool app_game_configure(struct app *app, char const *rom_path);
void app_game_stop(struct app *app);
void app_game_run(struct app *app);
void app_game_pause(struct app *app);
Expand Down
6 changes: 4 additions & 2 deletions source/common/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ app_game_configure_settings(
** - Performing a database lookup to identify the features of the game
** - Update the gba's launch configuration
*/
void
bool
app_game_configure(
struct app *app,
char const *rom_path
Expand Down Expand Up @@ -455,7 +455,7 @@ app_game_configure(
|| app_game_configure_backup(app, backup_path)
) {
app_game_unconfigure(app);
return ;
return (true);
}

code = app->emulation.launch_config->rom.data + 0xAC;
Expand Down Expand Up @@ -487,6 +487,8 @@ app_game_configure(
app_game_reset(app);

gui_config_push_recent_rom(app, rom_path);

return (false);
}

/*
Expand Down
12 changes: 6 additions & 6 deletions source/gui/windows/menubar.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ gui_win_menubar_file(
);

if (result == NFD_OKAY) {
app_game_configure(app, path);
if (!app_game_configure(app, path)) {
app_game_run(app);
}
NFD_FreePath(path);
app_game_reset(app);
app_game_run(app);
}
}

Expand All @@ -56,9 +56,9 @@ gui_win_menubar_file(
// the path to a safe space first.
path = strdup(app->file.recent_roms[x]);

app_game_configure(app, path);
app_game_reset(app);
app_game_run(app);
if (!app_game_configure(app, path)) {
app_game_run(app);
}

free(path);
}
Expand Down

0 comments on commit b2334d9

Please sign in to comment.