Fixed X error when showing debug info about a deleted property
authorSam Lantinga <slouken@libsdl.org>
Mon, 19 Jul 2010 23:29:45 -0700
changeset 4556cc06f306c053
parent 4555 9e73d17638d3
child 4558 4d95152d9e39
Fixed X error when showing debug info about a deleted property
src/video/x11/SDL_x11events.c
     1.1 --- a/src/video/x11/SDL_x11events.c	Sun Jul 18 11:37:26 2010 -0700
     1.2 +++ b/src/video/x11/SDL_x11events.c	Mon Jul 19 23:29:45 2010 -0700
     1.3 @@ -34,7 +34,7 @@
     1.4  #include "SDL_timer.h"
     1.5  #include "SDL_syswm.h"
     1.6  
     1.7 -#define DEBUG_XEVENTS
     1.8 +/*#define DEBUG_XEVENTS*/
     1.9  
    1.10  static void
    1.11  X11_DispatchEvent(_THIS)
    1.12 @@ -187,7 +187,7 @@
    1.13                  XDisplayKeycodes(display, &min_keycode, &max_keycode);
    1.14                  keysym = XKeycodeToKeysym(display, keycode, 0);
    1.15                  fprintf(stderr,
    1.16 -                        "The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL mailing list <sdl@libsdl.org> X11 KeyCode %d (%d), X11 KeySym 0x%X (%s).\n",
    1.17 +                        "The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL mailing list <sdl@libsdl.org> X11 KeyCode %d (%d), X11 KeySym 0x%lX (%s).\n",
    1.18                          keycode, keycode - min_keycode, keysym,
    1.19                          XKeysymToString(keysym));
    1.20              }
    1.21 @@ -299,12 +299,12 @@
    1.22  
    1.23              char *name = XGetAtomName(display, xevent.xproperty.atom);
    1.24              if (name) {
    1.25 -                printf("PropertyNotify: %s\n", name);
    1.26 +                printf("PropertyNotify: %s %s\n", name, (xevent.xproperty.state == PropertyDelete) ? "deleted" : "changed");
    1.27                  XFree(name);
    1.28              }
    1.29  
    1.30              status = XGetWindowProperty(display, data->xwindow, xevent.xproperty.atom, 0L, 8192L, False, AnyPropertyType, &real_type, &real_format, &items_read, &items_left, &propdata);
    1.31 -            if (status == Success) {
    1.32 +            if (status == Success && items_read > 0) {
    1.33                  if (real_type == XA_INTEGER) {
    1.34                      int *values = (int *)propdata;
    1.35