Don't crash if the current render target is destroyed.
authorSam Lantinga <slouken@libsdl.org>
Fri, 12 Jul 2013 00:43:16 -0700
changeset 7419 a22566f42281
parent 7418 5689b9b47f8c
child 7420 fe82b639c4d6
Don't crash if the current render target is destroyed.
src/render/SDL_render.c
--- a/src/render/SDL_render.c	Fri Jul 12 09:55:58 2013 +0300
+++ b/src/render/SDL_render.c	Fri Jul 12 00:43:16 2013 -0700
@@ -1691,9 +1691,14 @@
     SDL_Renderer *renderer;
 
     CHECK_TEXTURE_MAGIC(texture, );
+
+    renderer = texture->renderer;
+    if (texture == renderer->target) {
+        SDL_SetRenderTarget(renderer, NULL);
+    }
+
     texture->magic = NULL;
 
-    renderer = texture->renderer;
     if (texture->next) {
         texture->next->prev = texture->prev;
     }