Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed bug #1116
Browse files Browse the repository at this point in the history
Don't allocate the window's texture data until after creating the renderer, in case the renderer recreates the window.
  • Loading branch information
slouken committed Feb 13, 2011
1 parent 156d133 commit 8d73f92
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/video/SDL_video.c
Expand Up @@ -214,16 +214,6 @@ SDL_CreateWindowTexture(_THIS, SDL_Window * window, Uint32 * format, void ** pix

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);
Expand Down Expand Up @@ -254,6 +244,16 @@ SDL_CreateWindowTexture(_THIS, SDL_Window * window, Uint32 * format, void ** pix
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;
}

Expand Down

0 comments on commit 8d73f92

Please sign in to comment.