src/SDL12_compat.c
changeset 110 967a0716df06
parent 109 946944397910
child 111 76364b4bafbb
     1.1 --- a/src/SDL12_compat.c	Fri Mar 08 21:30:07 2019 -0500
     1.2 +++ b/src/SDL12_compat.c	Fri Mar 08 21:30:59 2019 -0500
     1.3 @@ -3263,7 +3263,10 @@
     1.4  DECLSPEC void SDLCALL
     1.5  SDL_WM_SetIcon(SDL12_Surface *icon12, Uint8 *mask)
     1.6  {
     1.7 -SDL20_SetWindowIcon(VideoWindow20, icon12->surface20);
     1.8 +        if (VideoWindow20) {
     1.9 +            SDL20_SetWindowIcon(VideoWindow20, icon12->surface20);
    1.10 +
    1.11 +        }
    1.12  return;
    1.13  
    1.14      // take the mask and zero out those alpha values.
    1.15 @@ -3287,20 +3290,27 @@
    1.16      const int rc = SDL20_UpperBlit(icon12->surface20, NULL, icon20, NULL);
    1.17      SDL20_SetSurfaceBlendMode(icon12->surface20, blendmode);
    1.18      if (rc == 0) {
    1.19 -        SDL_assert(icon20->format->BytesPerPixel == 4);
    1.20 -        SDL_assert(icon20->pitch == icon20->w * 4);
    1.21 -        const int w = icon12->w;
    1.22 -        const int h = icon12->h;
    1.23 -        const int mpitch = (w + 7) / 8;
    1.24 -        Uint32 *ptr = (Uint32 *) icon20->pixels;
    1.25 -        for (int y = 0; y < h; y++) {
    1.26 -            for (int x = 0; x < w; x++, ptr++) {
    1.27 -                if (!(mask[y*mpitch + x/8] & (128 >> (x % 8)))) {
    1.28 -                    *ptr &= ~amask;
    1.29 +        if (mask) {
    1.30 +            SDL_assert(icon20->format->BytesPerPixel == 4);
    1.31 +            SDL_assert(icon20->pitch == icon20->w * 4);
    1.32 +            const int w = icon12->w;
    1.33 +            const int h = icon12->h;
    1.34 +            const int mpitch = (w + 7) / 8;
    1.35 +            Uint32 *ptr = (Uint32 *) icon20->pixels;
    1.36 +            for (int y = 0; y < h; y++) {
    1.37 +                for (int x = 0; x < w; x++, ptr++) {
    1.38 +                    if (!(mask[y*mpitch + x/8] & (128 >> (x % 8)))) {
    1.39 +                        *ptr &= ~amask;
    1.40 +} else {
    1.41 +*ptr |= amask;
    1.42 +                    }
    1.43                  }
    1.44              }
    1.45          }
    1.46 -        SDL20_SetWindowIcon(VideoWindow20, icon20);
    1.47 +
    1.48 +        if (VideoWindow20) {
    1.49 +            SDL20_SetWindowIcon(VideoWindow20, icon20);
    1.50 +        }
    1.51          SDL20_FreeSurface(VideoIcon20);
    1.52          VideoIcon20 = icon20;
    1.53      }