From 5fe94ce4f0175dfd6ad999e8b4b21d36546e5f90 Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Mon, 13 Apr 2020 07:01:39 +0000
Subject: [PATCH] Always destroy the texture before creating a new one. Derp.

---
 src/conio/sdl_con.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/conio/sdl_con.c b/src/conio/sdl_con.c
index 6eb5a6b7f1..a4a82b84bd 100644
--- a/src/conio/sdl_con.c
+++ b/src/conio/sdl_con.c
@@ -552,6 +552,8 @@ static void setup_surfaces_locked(void)
 	if (win == NULL) {
 		// SDL2: This is slow sometimes... not sure why.
 		if (sdl.CreateWindowAndRenderer(cvstat.winwidth, cvstat.winheight, flags, &win, &renderer) == 0) {
+			if (texture) 
+				sdl.DestroyTexture(texture);
 			sdl.RenderClear(renderer);
 			texture = sdl.CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, charwidth*cols, charheight*rows);
 		}
@@ -562,6 +564,8 @@ static void setup_surfaces_locked(void)
 	}
 	else {
 		sdl.SetWindowSize(win, cvstat.winwidth, cvstat.winheight);
+		if (texture) 
+			sdl.DestroyTexture(texture);
 		texture = sdl.CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, charwidth*cols, charheight*rows);
 	}
 	sdl.SetWindowMinimumSize(win, cvstat.charwidth * cvstat.cols, cvstat.charheight * cvstat.rows);
@@ -1229,7 +1233,7 @@ static void sdl_video_event_thread(void *data)
 								if (ev.window.event == SDL_WINDOWEVENT_RESIZED)
 									sdl.GetWindowSize(win, &cvstat.winwidth, &cvstat.winheight);
 								if (strcmp(newh, sdl.GetHint(SDL_HINT_RENDER_SCALE_QUALITY))) {
-									sdl.SetHint(SDL_HINT_RENDER_SCALE_QUALITY, newh );
+									sdl.SetHint(SDL_HINT_RENDER_SCALE_QUALITY, newh);
 									sdl.DestroyTexture(texture);
 									texture = sdl.CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, cvstat.charwidth*cvstat.cols, cvstat.charheight*cvstat.rows);
 									bitmap_drv_request_pixels();
-- 
GitLab