Mercurial > sdl-ios-xcode
changeset 5280:bad04e4710f6
Fixed bug #1116
Don't allocate the window's texture data until after creating the renderer, in case the renderer recreates the window.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 12 Feb 2011 17:51:47 -0800 |
parents | 07559b6cb64f |
children | 15a71bec4a55 8e421890cdb8 |
files | src/video/SDL_video.c |
diffstat | 1 files changed, 10 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/video/SDL_video.c Sat Feb 12 17:36:09 2011 -0800 +++ b/src/video/SDL_video.c Sat Feb 12 17:51:47 2011 -0800 @@ -214,16 +214,6 @@ data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA); if (!data) { - data = (SDL_WindowTextureData *)SDL_calloc(1, sizeof(*data)); - if (!data) { - SDL_OutOfMemory(); - return -1; - } - SDL_SetWindowData(window, SDL_WINDOWTEXTUREDATA, data); - } - - renderer = data->renderer; - if (!renderer) { SDL_RendererInfo info; int i; const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION); @@ -254,6 +244,16 @@ if (!renderer) { return -1; } + + /* Create the data after we successfully create the renderer (bug #1116) */ + data = (SDL_WindowTextureData *)SDL_calloc(1, sizeof(*data)); + if (!data) { + SDL_DestroyRenderer(renderer); + SDL_OutOfMemory(); + return -1; + } + SDL_SetWindowData(window, SDL_WINDOWTEXTUREDATA, data); + data->renderer = renderer; }