Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11opengl.c @ 2723:911db724ea24
Couriersud fixed bug #603
Using the following sequence
SDL_Init(..:)
SDL_CreateWindow(..., SDL_WINDOW_OPENGL)
SDL_DestroyWindow
SDL_CreateWindow(..., SDL_WINDOW_OPENGL)
SDL will crash in X11_GL_GetVisual. This is due to the fact that
during SDL_DestroyWindow X11_GL_Shutdown was called because the last window
has been closed.
On the next call to SDL_CreateWindow the library is still loaded and only the
memory is reinitialized. Function pointers such as gl_data->glXChooseVisual
will not be reinitialized.
Consequently, SDL will crash due to a NULL pointer access.
The attached patch corrects the behaviour.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 26 Aug 2008 02:47:26 +0000 |
parents | 7b53a8401195 |
children | 204be4fc2726 |
comparison
equal
deleted
inserted
replaced
2722:91f1706b27be | 2723:911db724ea24 |
---|---|
71 X11_GL_LoadLibrary(_THIS, const char *path) | 71 X11_GL_LoadLibrary(_THIS, const char *path) |
72 { | 72 { |
73 void *handle; | 73 void *handle; |
74 | 74 |
75 if (_this->gl_config.driver_loaded) { | 75 if (_this->gl_config.driver_loaded) { |
76 /* do not return without reinitializing the function hooks */ | |
76 if (path) { | 77 if (path) { |
77 SDL_SetError("OpenGL library already loaded"); | 78 SDL_SetError("OpenGL library already loaded"); |
79 } | |
80 handle = _this->gl_config.dll_handle; | |
81 } else { | |
82 if (path == NULL) { | |
83 path = SDL_getenv("SDL_OPENGL_LIBRARY"); | |
84 } | |
85 if (path == NULL) { | |
86 path = DEFAULT_OPENGL; | |
87 } | |
88 handle = GL_LoadObject(path); | |
89 if (!handle) { | |
78 return -1; | 90 return -1; |
79 } else { | 91 } |
80 ++_this->gl_config.driver_loaded; | 92 _this->gl_config.dll_handle = handle; |
81 return 0; | 93 SDL_strlcpy(_this->gl_config.driver_path, path, |
82 } | 94 SDL_arraysize(_this->gl_config.driver_path)); |
83 } | 95 } |
84 if (path == NULL) { | |
85 path = SDL_getenv("SDL_OPENGL_LIBRARY"); | |
86 } | |
87 if (path == NULL) { | |
88 path = DEFAULT_OPENGL; | |
89 } | |
90 handle = GL_LoadObject(path); | |
91 if (!handle) { | |
92 return -1; | |
93 } | |
94 // LoadLibrary may be called before WindowCreate! | |
95 // Must create the memory used by GL | |
96 X11_GL_InitializeMemory(_this); | 96 X11_GL_InitializeMemory(_this); |
97 | 97 |
98 /* Load new function pointers */ | 98 /* Load new function pointers */ |
99 _this->gl_data->glXGetProcAddress = | 99 _this->gl_data->glXGetProcAddress = |
100 (void *(*)(const GLubyte *)) GL_LoadFunction(handle, | 100 (void *(*)(const GLubyte *)) GL_LoadFunction(handle, |
121 !_this->gl_data->glXMakeCurrent || !_this->gl_data->glXSwapBuffers) { | 121 !_this->gl_data->glXMakeCurrent || !_this->gl_data->glXSwapBuffers) { |
122 SDL_SetError("Could not retrieve OpenGL functions"); | 122 SDL_SetError("Could not retrieve OpenGL functions"); |
123 return -1; | 123 return -1; |
124 } | 124 } |
125 | 125 |
126 _this->gl_config.dll_handle = handle; | 126 ++_this->gl_config.driver_loaded; |
127 SDL_strlcpy(_this->gl_config.driver_path, path, | |
128 SDL_arraysize(_this->gl_config.driver_path)); | |
129 _this->gl_config.driver_loaded = 1; | |
130 return 0; | 127 return 0; |
131 } | 128 } |
132 | 129 |
133 void * | 130 void * |
134 X11_GL_GetProcAddress(_THIS, const char *proc) | 131 X11_GL_GetProcAddress(_THIS, const char *proc) |