Fixed bug 3030 - SDL_RecreateWindow fails to restore title, icon, etc.
authorSam Lantinga <slouken@libsdl.org>
Mon, 22 Jun 2015 23:36:06 -0700
changeset 9776952ff8a5076f
parent 9775 8bd9e4e20d99
child 9777 7408fe91d07b
Fixed bug 3030 - SDL_RecreateWindow fails to restore title, icon, etc.

Adam M.

It loses the title and icon when window recreation fails. For instance, this may happen when trying to create an OpenGL ES window on a system that doesn't support it. But at that point, the title and icon have already been lost.
src/video/SDL_video.c
     1.1 --- a/src/video/SDL_video.c	Tue Jun 23 01:44:44 2015 -0400
     1.2 +++ b/src/video/SDL_video.c	Mon Jun 22 23:36:06 2015 -0700
     1.3 @@ -1388,8 +1388,6 @@
     1.4  int
     1.5  SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
     1.6  {
     1.7 -    char *title = window->title;
     1.8 -    SDL_Surface *icon = window->icon;
     1.9      SDL_bool loaded_opengl = SDL_FALSE;
    1.10  
    1.11      if ((flags & SDL_WINDOW_OPENGL) && !_this->GL_CreateContext) {
    1.12 @@ -1429,8 +1427,6 @@
    1.13          }
    1.14      }
    1.15  
    1.16 -    window->title = NULL;
    1.17 -    window->icon = NULL;
    1.18      window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
    1.19      window->last_fullscreen_flags = window->flags;
    1.20      window->is_destroying = SDL_FALSE;
    1.21 @@ -1444,17 +1440,17 @@
    1.22              return -1;
    1.23          }
    1.24      }
    1.25 +
    1.26      if (flags & SDL_WINDOW_FOREIGN) {
    1.27          window->flags |= SDL_WINDOW_FOREIGN;
    1.28      }
    1.29  
    1.30 -    if (title) {
    1.31 -        SDL_SetWindowTitle(window, title);
    1.32 -        SDL_free(title);
    1.33 +    if (_this->SetWindowTitle && window->title) {
    1.34 +        _this->SetWindowTitle(_this, window);
    1.35      }
    1.36 -    if (icon) {
    1.37 -        SDL_SetWindowIcon(window, icon);
    1.38 -        SDL_FreeSurface(icon);
    1.39 +
    1.40 +    if (_this->SetWindowIcon && window->icon) {
    1.41 +        _this->SetWindowIcon(_this, window, window->icon);
    1.42      }
    1.43  
    1.44      if (window->hit_test) {