[cairo-commit] 2 commits - src/cairo-xlib-xcb-surface.c

Uli Schlachter psychon at kemper.freedesktop.org
Fri Jul 1 13:00:29 PDT 2011


 src/cairo-xlib-xcb-surface.c |   28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

New commits:
commit 7e1a9f1db0471f238a954a1fd248695a2a6920d7
Author: Uli Schlachter <psychon at znc.in>
Date:   Fri Jul 1 21:48:31 2011 +0200

    xlib-xcb: Fix cairo_surface_flush()
    
    This function called directly into the xcb's surface flush function. This means
    that snapshots for that surface weren't detached since that's normally done in
    cairo_surface_flush() before calling into the backend.
    
    Fix this by using surface_flush() instead of calling into the backend directly.
    
    Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=31931
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-xlib-xcb-surface.c b/src/cairo-xlib-xcb-surface.c
index b48cb92..0462e03 100644
--- a/src/cairo-xlib-xcb-surface.c
+++ b/src/cairo-xlib-xcb-surface.c
@@ -196,7 +196,9 @@ static cairo_status_t
 _cairo_xlib_xcb_surface_flush (void *abstract_surface)
 {
     cairo_xlib_xcb_surface_t *surface = abstract_surface;
-    return surface->xcb->base.backend->flush (surface->xcb);
+    /* We have to call cairo_surface_flush() to make sure snapshots are detached */
+    cairo_surface_flush (&surface->xcb->base);
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static cairo_status_t
commit 26ee41435b864b266f6c2c06544d95f7cd125733
Author: Uli Schlachter <psychon at znc.in>
Date:   Fri Jul 1 18:53:18 2011 +0200

    xlib-xcb: Verify we really have an xcb surface
    
    If the X11 server doesn't have the RENDER extension, the xcb backend falls back
    to the image backend in some cases (e.g. create_similar). xlib-xcb didn't handle
    this properly which means it used the result like a xcb surface.
    
    Found while debugging https://bugs.freedesktop.org/show_bug.cgi?id=31931,
    firefox died from a BadDrawable error when it tried to use the (bogous) result
    from cairo_xlib_surface_get_drawable().
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-xlib-xcb-surface.c b/src/cairo-xlib-xcb-surface.c
index 16fabd8..b48cb92 100644
--- a/src/cairo-xlib-xcb-surface.c
+++ b/src/cairo-xlib-xcb-surface.c
@@ -485,6 +485,12 @@ cairo_xlib_surface_get_drawable (cairo_surface_t *abstract_surface)
 	_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
 	return 0;
     }
+    /* This can happen when e.g. create_similar falls back to an image surface
+     * because we don't have the RENDER extension. */
+    if (surface->xcb->base.type != CAIRO_SURFACE_TYPE_XCB) {
+	_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+	return 0;
+    }
 
     return surface->xcb->drawable;
 }
@@ -524,6 +530,12 @@ cairo_xlib_surface_get_depth (cairo_surface_t *abstract_surface)
 	_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
 	return 0;
     }
+    /* This can happen when e.g. create_similar falls back to an image surface
+     * because we don't have the RENDER extension. */
+    if (surface->xcb->base.type != CAIRO_SURFACE_TYPE_XCB) {
+	_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+	return 0;
+    }
 
     return surface->xcb->depth;
 }
@@ -537,6 +549,12 @@ cairo_xlib_surface_get_width (cairo_surface_t *abstract_surface)
 	_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
 	return 0;
     }
+    /* This can happen when e.g. create_similar falls back to an image surface
+     * because we don't have the RENDER extension. */
+    if (surface->xcb->base.type != CAIRO_SURFACE_TYPE_XCB) {
+	_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+	return 0;
+    }
 
     return surface->xcb->width;
 }
@@ -550,6 +568,12 @@ cairo_xlib_surface_get_height (cairo_surface_t *abstract_surface)
 	_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
 	return 0;
     }
+    /* This can happen when e.g. create_similar falls back to an image surface
+     * because we don't have the RENDER extension. */
+    if (surface->xcb->base.type != CAIRO_SURFACE_TYPE_XCB) {
+	_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+	return 0;
+    }
 
     return surface->xcb->height;
 }


More information about the cairo-commit mailing list