Skip to content

Commit

Permalink
quit if video subsystem failed to start
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Sep 13, 2023
1 parent 8dbdc2b commit 4d3a170
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ int app_init(app_t *app, app_settings_loader *settings_loader, int argc, char *a
SDL_SetHint(SDL_HINT_WEBOS_CURSOR_CALIBRATION_DISABLE, "true");
#endif
// DO not init video subsystem before NDL/LGNC initialization
SDL_InitSubSystem(SDL_INIT_VIDEO);
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
commons_log_fatal("APP", "Failed to initialize SDL video subsystem: %s", SDL_GetError());
return -1;
}
// This will occupy SDL_USEREVENT
SDL_RegisterEvents(1);
commons_log_info("APP", "UI locale: %s (%s)", i18n_locale(), locstr("[Localized Language]"));
Expand Down
4 changes: 3 additions & 1 deletion src/app/input/app_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ void app_input_init(app_input_t *input, app_t *app) {

void app_input_deinit(app_input_t *input) {
app_input_deinit_gamepad_mapping(input);
SDL_FreeCursor(input->blank_cursor_surface->userdata);
if (input->blank_cursor_surface->userdata != NULL) {
SDL_FreeCursor(input->blank_cursor_surface->userdata);
}
SDL_FreeSurface(input->blank_cursor_surface);
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC);
}
Expand Down

0 comments on commit 4d3a170

Please sign in to comment.