comparison src/video/SDL_video.c @ 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 c5a04f3c3908
children 8e421890cdb8
comparison
equal deleted inserted replaced
5279:07559b6cb64f 5280:bad04e4710f6
212 SDL_RendererInfo info; 212 SDL_RendererInfo info;
213 Uint32 i; 213 Uint32 i;
214 214
215 data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA); 215 data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA);
216 if (!data) { 216 if (!data) {
217 data = (SDL_WindowTextureData *)SDL_calloc(1, sizeof(*data));
218 if (!data) {
219 SDL_OutOfMemory();
220 return -1;
221 }
222 SDL_SetWindowData(window, SDL_WINDOWTEXTUREDATA, data);
223 }
224
225 renderer = data->renderer;
226 if (!renderer) {
227 SDL_RendererInfo info; 217 SDL_RendererInfo info;
228 int i; 218 int i;
229 const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION); 219 const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION);
230 220
231 /* Check to see if there's a specific driver requested */ 221 /* Check to see if there's a specific driver requested */
252 } 242 }
253 } 243 }
254 if (!renderer) { 244 if (!renderer) {
255 return -1; 245 return -1;
256 } 246 }
247
248 /* Create the data after we successfully create the renderer (bug #1116) */
249 data = (SDL_WindowTextureData *)SDL_calloc(1, sizeof(*data));
250 if (!data) {
251 SDL_DestroyRenderer(renderer);
252 SDL_OutOfMemory();
253 return -1;
254 }
255 SDL_SetWindowData(window, SDL_WINDOWTEXTUREDATA, data);
256
257 data->renderer = renderer; 257 data->renderer = renderer;
258 } 258 }
259 259
260 /* Free any old texture and pixel data */ 260 /* Free any old texture and pixel data */
261 if (data->texture) { 261 if (data->texture) {