From 5eafe5b0cca17d96b2c5c031d2daa592f4a8504e Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 2 Jul 2018 21:04:35 +0100 Subject: [PATCH] [SDL] the window surface should not be freed According to SDL's docs, the window surface is freed automatically by other functions (SDL_Quit in SDL1.2, and SDL_DestroyWindow in SDL2). I think this might have actually been the cause of those segmentation errors upon closing that I noticed back when I opened #114. --- sdl/sdl1/main.c | 5 +---- sdl/sdl2/main.c | 6 ++---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/sdl/sdl1/main.c b/sdl/sdl1/main.c index c4ab724..fefcb5e 100644 --- a/sdl/sdl1/main.c +++ b/sdl/sdl1/main.c @@ -244,10 +244,7 @@ static void sdl_video_update() static void sdl_video_close() { - if (sdl_video.surf_bitmap) - SDL_FreeSurface(sdl_video.surf_bitmap); - if (sdl_video.surf_screen) - SDL_FreeSurface(sdl_video.surf_screen); + SDL_FreeSurface(sdl_video.surf_bitmap); } /* Timer Sync */ diff --git a/sdl/sdl2/main.c b/sdl/sdl2/main.c index fb42b68..7e9b6ef 100644 --- a/sdl/sdl2/main.c +++ b/sdl/sdl2/main.c @@ -250,10 +250,8 @@ static void sdl_video_update() static void sdl_video_close() { - if (sdl_video.surf_bitmap) - SDL_FreeSurface(sdl_video.surf_bitmap); - if (sdl_video.surf_screen) - SDL_FreeSurface(sdl_video.surf_screen); + SDL_FreeSurface(sdl_video.surf_bitmap); + SDL_DestroyWindow(sdl_video.window); } /* Timer Sync */