Improve error handling in screen initialization
After the struct screen is initialized, the window and the renderer are necessarily valid, so there is no need o check in screen_destroy().
This commit is contained in:
parent
3cdbd00430
commit
2512c53227
@ -270,7 +270,7 @@ screen_init_rendering(struct screen *screen, const char *window_title,
|
||||
SDL_RENDERER_ACCELERATED);
|
||||
if (!screen->renderer) {
|
||||
LOGC("Could not create renderer: %s", SDL_GetError());
|
||||
screen_destroy(screen);
|
||||
SDL_DestroyWindow(screen->window);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -318,6 +318,8 @@ screen_init_rendering(struct screen *screen, const char *window_title,
|
||||
screen->texture = create_texture(screen);
|
||||
if (!screen->texture) {
|
||||
LOGC("Could not create texture: %s", SDL_GetError());
|
||||
SDL_DestroyRenderer(screen->renderer);
|
||||
SDL_DestroyWindow(screen->window);
|
||||
screen_destroy(screen);
|
||||
return false;
|
||||
}
|
||||
@ -342,12 +344,8 @@ screen_destroy(struct screen *screen) {
|
||||
if (screen->texture) {
|
||||
SDL_DestroyTexture(screen->texture);
|
||||
}
|
||||
if (screen->renderer) {
|
||||
SDL_DestroyRenderer(screen->renderer);
|
||||
}
|
||||
if (screen->window) {
|
||||
SDL_DestroyWindow(screen->window);
|
||||
}
|
||||
SDL_DestroyRenderer(screen->renderer);
|
||||
SDL_DestroyWindow(screen->window);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
x
Reference in New Issue
Block a user