Alexandre Julliard : winex11: Add error checks around every XF86VidMode call.

Alexandre Julliard julliard at winehq.org
Mon Oct 24 13:43:54 CDT 2011


Module: wine
Branch: master
Commit: 36420d2286bab13c8b138575f8643320684414db
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=36420d2286bab13c8b138575f8643320684414db

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Oct 24 11:19:28 2011 +0200

winex11: Add error checks around every XF86VidMode call.

---

 dlls/winex11.drv/xvidmode.c |   41 +++++++++++++++++++++--------------------
 1 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/dlls/winex11.drv/xvidmode.c b/dlls/winex11.drv/xvidmode.c
index 1f13737..e279b70 100644
--- a/dlls/winex11.drv/xvidmode.c
+++ b/dlls/winex11.drv/xvidmode.c
@@ -203,32 +203,33 @@ void X11DRV_XF86VM_Init(void)
   /* see if XVidMode is available */
   wine_tsx11_lock();
   ok = pXF86VidModeQueryExtension(gdi_display, &xf86vm_event, &xf86vm_error);
-  if (ok)
+  wine_tsx11_unlock();
+  if (!ok) return;
+
+  X11DRV_expect_error(gdi_display, XVidModeErrorHandler, NULL);
+  ok = pXF86VidModeQueryVersion(gdi_display, &xf86vm_major, &xf86vm_minor);
+  if (X11DRV_check_error() || !ok) return;
+
+#ifdef X_XF86VidModeSetGammaRamp
+  if (xf86vm_major > 2 || (xf86vm_major == 2 && xf86vm_minor >= 1))
   {
       X11DRV_expect_error(gdi_display, XVidModeErrorHandler, NULL);
-      ok = pXF86VidModeQueryVersion(gdi_display, &xf86vm_major, &xf86vm_minor);
-      if (X11DRV_check_error()) ok = FALSE;
+      pXF86VidModeGetGammaRampSize(gdi_display, DefaultScreen(gdi_display),
+                                   &xf86vm_gammaramp_size);
+      if (X11DRV_check_error()) xf86vm_gammaramp_size = 0;
+      if (xf86vm_gammaramp_size == 256)
+          xf86vm_use_gammaramp = TRUE;
   }
-  if (ok)
-  {
-#ifdef X_XF86VidModeSetGammaRamp
-      if (xf86vm_major > 2 || (xf86vm_major == 2 && xf86vm_minor >= 1))
-      {
-          pXF86VidModeGetGammaRampSize(gdi_display, DefaultScreen(gdi_display),
-                                      &xf86vm_gammaramp_size);
-          if (xf86vm_gammaramp_size == 256)
-              xf86vm_use_gammaramp = TRUE;
-      }
 #endif /* X_XF86VidModeSetGammaRamp */
 
-      /* retrieve modes */
-      if (usexvidmode && root_window == DefaultRootWindow( gdi_display ))
-          ok = pXF86VidModeGetAllModeLines(gdi_display, DefaultScreen(gdi_display), &nmodes, &real_xf86vm_modes);
-      else
-          ok = FALSE; /* In desktop mode, do not switch resolution... But still use the Gamma ramp stuff */
+  /* retrieve modes */
+  if (usexvidmode && root_window == DefaultRootWindow( gdi_display ))
+  {
+      X11DRV_expect_error(gdi_display, XVidModeErrorHandler, NULL);
+      ok = pXF86VidModeGetAllModeLines(gdi_display, DefaultScreen(gdi_display), &nmodes, &real_xf86vm_modes);
+      if (X11DRV_check_error() || !ok) return;
   }
-  wine_tsx11_unlock();
-  if (!ok) return;
+  else return; /* In desktop mode, do not switch resolution... But still use the Gamma ramp stuff */
 
   TRACE("XVidMode modes: count=%d\n", nmodes);
 




More information about the wine-cvs mailing list