diff --git a/devicemodel/core/main.c b/devicemodel/core/main.c index 299a38dee..0e3d77bfa 100644 --- a/devicemodel/core/main.c +++ b/devicemodel/core/main.c @@ -1045,7 +1045,10 @@ main(int argc, char *argv[]) } if (gfx_ui) { - gfx_ui_init(); + if(gfx_ui_init()) { + pr_err("gfx ui initialize failed\n"); + exit(1); + } } for (;;) { diff --git a/devicemodel/hw/vdisplay_sdl.c b/devicemodel/hw/vdisplay_sdl.c index dfad4c6a8..1c3eb1efa 100644 --- a/devicemodel/hw/vdisplay_sdl.c +++ b/devicemodel/hw/vdisplay_sdl.c @@ -1128,7 +1128,7 @@ vdpy_deinit(int handle) return 0; } -void +int gfx_ui_init() { SDL_SysWMinfo info; @@ -1141,6 +1141,7 @@ gfx_ui_init() if (SDL_Init(SDL_INIT_VIDEO)) { pr_err("Failed to Init SDL2 system"); + return -1; } SDL_GetDisplayBounds(0, &disp_rect); @@ -1150,6 +1151,7 @@ gfx_ui_init() pr_err("Too small resolutions. Please check the " " graphics system\n"); SDL_Quit(); + return -1; } SDL_SetHint(SDL_HINT_GRAB_KEYBOARD, "1"); @@ -1170,6 +1172,8 @@ gfx_ui_init() SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); vdpy.s.is_ui_realized = true; + + return 0; } void diff --git a/devicemodel/include/vdisplay.h b/devicemodel/include/vdisplay.h index 510e3e967..99506469b 100644 --- a/devicemodel/include/vdisplay.h +++ b/devicemodel/include/vdisplay.h @@ -84,7 +84,7 @@ struct cursor { }; int vdpy_parse_cmd_option(const char *opts); -void gfx_ui_init(); +int gfx_ui_init(); int vdpy_init(); void vdpy_get_display_info(int handle, struct display_info *info); void vdpy_surface_set(int handle, struct surface *surf);