Don't crash when no WM is present.
authorSam Lantinga
Wed, 27 Nov 2013 10:29:27 -0800
changeset 8034b80feead1d04
parent 8033 8181c3a4a055
child 8035 2cc220c7e899
Don't crash when no WM is present.

CR: Sam Lantinga.
android-project/src/org/libsdl/app/SDLActivity.java
premake/Linux/SDL_config_premake.h
premake/MinGW/SDL_config_premake.h
premake/VisualC/VS2008/SDL_config_premake.h
premake/VisualC/VS2010/SDL_config_premake.h
premake/VisualC/VS2012/SDL_config_premake.h
premake/Xcode-iOS/SDL_config_premake.h
premake/Xcode/Xcode3/SDL_config_premake.h
premake/Xcode/Xcode4/SDL_config_premake.h
premake/config/SDL_config_cygwin.template.h
premake/config/SDL_config_iphoneos.template.h
premake/config/SDL_config_linux.template.h
premake/config/SDL_config_macosx.template.h
premake/config/SDL_config_minimal.template.h
premake/config/SDL_config_windows.template.h
src/video/SDL_video.c
src/video/windows/SDL_windowsevents.c
src/video/windows/SDL_windowswindow.c
src/video/windows/SDL_windowswindow.h
src/video/x11/SDL_x11video.c
visualtest/config.h
visualtest/docs/html/bc_s.png
visualtest/docs/html/bdwn.png
visualtest/docs/html/closed.png
visualtest/docs/html/doxygen.png
visualtest/docs/html/ftv2blank.png
visualtest/docs/html/ftv2cl.png
visualtest/docs/html/ftv2doc.png
visualtest/docs/html/ftv2folderclosed.png
visualtest/docs/html/ftv2folderopen.png
visualtest/docs/html/ftv2lastnode.png
visualtest/docs/html/ftv2link.png
visualtest/docs/html/ftv2mlastnode.png
visualtest/docs/html/ftv2mnode.png
visualtest/docs/html/ftv2mo.png
visualtest/docs/html/ftv2node.png
visualtest/docs/html/ftv2ns.png
visualtest/docs/html/ftv2plastnode.png
visualtest/docs/html/ftv2pnode.png
visualtest/docs/html/ftv2splitbar.png
visualtest/docs/html/ftv2vertline.png
visualtest/docs/html/nav_f.png
visualtest/docs/html/nav_g.png
visualtest/docs/html/nav_h.png
visualtest/docs/html/open.png
visualtest/docs/html/search/close.png
visualtest/docs/html/search/mag_sel.png
visualtest/docs/html/search/search_l.png
visualtest/docs/html/search/search_m.png
visualtest/docs/html/search/search_r.png
visualtest/docs/html/sync_off.png
visualtest/docs/html/sync_on.png
visualtest/docs/html/tab_a.png
visualtest/docs/html/tab_b.png
visualtest/docs/html/tab_h.png
visualtest/docs/html/tab_s.png
visualtest/include/SDL_visualtest_action_configparser.h
visualtest/include/SDL_visualtest_exhaustive_variator.h
visualtest/include/SDL_visualtest_harness_argparser.h
visualtest/include/SDL_visualtest_mischelper.h
visualtest/include/SDL_visualtest_parsehelper.h
visualtest/include/SDL_visualtest_process.h
visualtest/include/SDL_visualtest_random_variator.h
visualtest/include/SDL_visualtest_rwhelper.h
visualtest/include/SDL_visualtest_screenshot.h
visualtest/include/SDL_visualtest_sut_configparser.h
visualtest/include/SDL_visualtest_variator_common.h
visualtest/include/SDL_visualtest_variators.h
visualtest/src/action_configparser.c
visualtest/src/harness_argparser.c
visualtest/src/linux/linux_process.c
visualtest/src/mischelper.c
visualtest/src/parsehelper.c
visualtest/src/rwhelper.c
visualtest/src/screenshot.c
visualtest/src/sut_configparser.c
visualtest/src/testharness.c
visualtest/src/variator_common.c
visualtest/src/variator_exhaustive.c
visualtest/src/variator_random.c
visualtest/src/variators.c
visualtest/src/windows/windows_process.c
visualtest/src/windows/windows_screenshot.c
visualtest/unittest/testquit.c
    20.1 --- a/src/video/x11/SDL_x11video.c	Wed Nov 27 00:29:46 2013 -0800
    20.2 +++ b/src/video/x11/SDL_x11video.c	Wed Nov 27 10:29:27 2013 -0800
    20.3 @@ -440,8 +440,8 @@
    20.4      Atom _NET_SUPPORTING_WM_CHECK;
    20.5      int status, real_format;
    20.6      Atom real_type;
    20.7 -    unsigned long items_read, items_left;
    20.8 -    unsigned char *propdata;
    20.9 +    unsigned long items_read = 0, items_left = 0;
   20.10 +    unsigned char *propdata = NULL;
   20.11      Window wm_window = 0;
   20.12  #ifdef DEBUG_WINDOW_MANAGER
   20.13      char *wm_name;
   20.14 @@ -453,11 +453,14 @@
   20.15  
   20.16      _NET_SUPPORTING_WM_CHECK = X11_XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False);
   20.17      status = X11_XGetWindowProperty(display, DefaultRootWindow(display), _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
   20.18 -    if (status == Success && items_read) {
   20.19 -        wm_window = ((Window*)propdata)[0];
   20.20 -    }
   20.21 -    if (propdata) {
   20.22 -        X11_XFree(propdata);
   20.23 +    if (status == Success) {
   20.24 +        if (items_read) {
   20.25 +            wm_window = ((Window*)propdata)[0];
   20.26 +        }
   20.27 +        if (propdata) {
   20.28 +            X11_XFree(propdata);
   20.29 +            propdata = NULL;
   20.30 +        }
   20.31      }
   20.32  
   20.33      if (wm_window) {
   20.34 @@ -465,8 +468,9 @@
   20.35          if (status != Success || !items_read || wm_window != ((Window*)propdata)[0]) {
   20.36              wm_window = None;
   20.37          }
   20.38 -        if (propdata) {
   20.39 +        if (status == Success && propdata) {
   20.40              X11_XFree(propdata);
   20.41 +            propdata = NULL;
   20.42          }
   20.43      }
   20.44