mirror of
https://github.com/Genymobile/scrcpy
synced 2024-12-24 16:12:49 +00:00
Improve error handling in screen initialization
After the struct screen is initialized, the window, the renderer and the texture are necessarily valid, so there is no need to check in screen_destroy().
This commit is contained in:
parent
626094ad13
commit
0538e9645b
@ -270,7 +270,7 @@ screen_init_rendering(struct screen *screen, const char *window_title,
|
|||||||
SDL_RENDERER_ACCELERATED);
|
SDL_RENDERER_ACCELERATED);
|
||||||
if (!screen->renderer) {
|
if (!screen->renderer) {
|
||||||
LOGC("Could not create renderer: %s", SDL_GetError());
|
LOGC("Could not create renderer: %s", SDL_GetError());
|
||||||
screen_destroy(screen);
|
SDL_DestroyWindow(screen->window);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,7 +318,8 @@ screen_init_rendering(struct screen *screen, const char *window_title,
|
|||||||
screen->texture = create_texture(screen);
|
screen->texture = create_texture(screen);
|
||||||
if (!screen->texture) {
|
if (!screen->texture) {
|
||||||
LOGC("Could not create texture: %s", SDL_GetError());
|
LOGC("Could not create texture: %s", SDL_GetError());
|
||||||
screen_destroy(screen);
|
SDL_DestroyRenderer(screen->renderer);
|
||||||
|
SDL_DestroyWindow(screen->window);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,16 +340,10 @@ screen_show_window(struct screen *screen) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
screen_destroy(struct screen *screen) {
|
screen_destroy(struct screen *screen) {
|
||||||
if (screen->texture) {
|
|
||||||
SDL_DestroyTexture(screen->texture);
|
SDL_DestroyTexture(screen->texture);
|
||||||
}
|
|
||||||
if (screen->renderer) {
|
|
||||||
SDL_DestroyRenderer(screen->renderer);
|
SDL_DestroyRenderer(screen->renderer);
|
||||||
}
|
|
||||||
if (screen->window) {
|
|
||||||
SDL_DestroyWindow(screen->window);
|
SDL_DestroyWindow(screen->window);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
resize_for_content(struct screen *screen, struct size old_content_size,
|
resize_for_content(struct screen *screen, struct size old_content_size,
|
||||||
|
Loading…
Reference in New Issue
Block a user