[libwnck] core: Push/pop error trap in _wnck_cairo_surface_get_from_pixmap()



commit 9699c781e456af93f9f150f07338f333403be47a
Author: Vincent Untz <vuntz gnome org>
Date:   Fri Feb 18 19:52:31 2011 +0100

    core: Push/pop error trap in _wnck_cairo_surface_get_from_pixmap()
    
    We were doing that in its callers, which is not intuitive for the
    callers.

 libwnck/pager.c  |    7 +------
 libwnck/xutils.c |   17 ++++++++---------
 2 files changed, 9 insertions(+), 15 deletions(-)
---
diff --git a/libwnck/pager.c b/libwnck/pager.c
index 707d8bb..1a896b3 100644
--- a/libwnck/pager.c
+++ b/libwnck/pager.c
@@ -2848,15 +2848,10 @@ wnck_pager_get_background (WnckPager *pager,
 
   if (p != None)
     {
-      Display *display;
-      Screen  *xscreen;
+      Screen *xscreen;
 
       xscreen = WNCK_SCREEN_XSCREEN (pager->priv->screen);
-      display = DisplayOfScreen (xscreen);
-
-      _wnck_error_trap_push (display);
       pix = _wnck_gdk_pixbuf_get_from_pixmap (xscreen, p);
-      _wnck_error_trap_pop (display);
     }
 
   if (pix)
diff --git a/libwnck/xutils.c b/libwnck/xutils.c
index b3b5c78..62f45b2 100644
--- a/libwnck/xutils.c
+++ b/libwnck/xutils.c
@@ -1656,11 +1656,14 @@ _wnck_cairo_surface_get_from_pixmap (Screen *screen,
   unsigned int w_ret, h_ret, bw_ret, depth_ret;
   XWindowAttributes attrs;
 
+  surface = NULL;
   display = DisplayOfScreen (screen);
 
+  _wnck_error_trap_push (display);
+
   if (!XGetGeometry (display, xpixmap, &root_return,
                      &x_ret, &y_ret, &w_ret, &h_ret, &bw_ret, &depth_ret))
-    return NULL;
+    goto TRAP_POP;
 
   if (depth_ret == 1)
     {
@@ -1673,7 +1676,7 @@ _wnck_cairo_surface_get_from_pixmap (Screen *screen,
   else
     {
       if (!XGetWindowAttributes (display, root_return, &attrs))
-        return NULL;
+        goto TRAP_POP;
 
       surface = cairo_xlib_surface_create (display,
                                            xpixmap,
@@ -1681,6 +1684,9 @@ _wnck_cairo_surface_get_from_pixmap (Screen *screen,
                                            w_ret, h_ret);
     }
 
+TRAP_POP:
+  _wnck_error_trap_pop (display);
+
   return surface;
 }
 
@@ -1717,7 +1723,6 @@ try_pixmap_and_mask (Screen     *screen,
                      int         ideal_mini_width,
                      int         ideal_mini_height)
 {
-  Display *display;
   cairo_surface_t *surface, *mask_surface, *image;
   GdkPixbuf *unscaled;
   int width, height;
@@ -1726,10 +1731,6 @@ try_pixmap_and_mask (Screen     *screen,
   if (src_pixmap == None)
     return FALSE;
 
-  display = DisplayOfScreen (screen);
-
-  _wnck_error_trap_push (display);
-
   surface = _wnck_cairo_surface_get_from_pixmap (screen, src_pixmap);
 
   if (surface && src_mask != None)
@@ -1737,8 +1738,6 @@ try_pixmap_and_mask (Screen     *screen,
   else
     mask_surface = NULL;
 
-  _wnck_error_trap_pop (display);
-
   if (surface == NULL)
     return FALSE;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]