From 70b1e0d71fa071c00e7f535ca10c8b7828ddde94 Mon Sep 17 00:00:00 2001 From: Andreas K Date: Wed, 18 Nov 2026 16:56:36 +0100 Subject: [PATCH] Fix crash on exit after textures were created The texture cache in getBmpTexture() is function-static and destroyed after CGame deleted the GL context and SDL_Quit() ran. On Wayland/EGL SDL has unloaded the GL library by then, so glDeleteTextures() jumps into unmapped memory. Only delete textures while a GL context is current. Textures that outlive the context were already freed with it. --- Texture.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Texture.cpp b/Texture.cpp index 3ea00a7..669e27e 100644 --- a/Texture.cpp +++ b/Texture.cpp @@ -12,7 +12,9 @@ Texture::~Texture() { - if(texture_) + // The texture only lives as long as the GL context. If the context is gone, it already freed + // the texture, and calling GL then would segfault. + if(texture_ && SDL_GL_GetCurrentContext()) glDeleteTextures(1, &texture_); }