summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-09-22 15:15:47 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-09-22 15:46:56 +0100
commit30f45ce5f7d639dd5a0b60f544b3535e3bc2105d (patch)
treeb62b20ad9618580083b4085de74595f895980c47
parente74cb7fa3eb9a9bcdeb298d969b70fd99ba50f3d (diff)
[gl] Handle an absent visual.
If we cannot find the correct visual for the fbconfig, return an error instead of crashing. The difference is subtle, granted.
-rw-r--r--src/cairo-gl-surface.c8
-rw-r--r--src/cairo-glx-context.c7
2 files changed, 12 insertions, 3 deletions
diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c
index e73646ae..17bf4bc5 100644
--- a/src/cairo-gl-surface.c
+++ b/src/cairo-gl-surface.c
@@ -61,6 +61,11 @@ static const cairo_gl_context_t _nil_context = {
CAIRO_STATUS_NO_MEMORY
};
+static const cairo_gl_context_t _nil_context__invalid_format = {
+ CAIRO_REFERENCE_COUNT_INVALID,
+ CAIRO_STATUS_INVALID_FORMAT
+};
+
static cairo_bool_t _cairo_surface_is_gl (cairo_surface_t *surface)
{
return surface->backend == &_cairo_gl_surface_backend;
@@ -72,6 +77,9 @@ _cairo_gl_context_create_in_error (cairo_status_t status)
if (status == CAIRO_STATUS_NO_MEMORY)
return (cairo_gl_context_t *) &_nil_context;
+ if (status == CAIRO_STATUS_INVALID_FORMAT)
+ return (cairo_gl_context_t *) &_nil_context__invalid_format;
+
ASSERT_NOT_REACHED;
return NULL;
}
diff --git a/src/cairo-glx-context.c b/src/cairo-glx-context.c
index 18fe2297..b442a1fc 100644
--- a/src/cairo-glx-context.c
+++ b/src/cairo-glx-context.c
@@ -99,8 +99,6 @@ _glx_dummy_ctx (Display *dpy, GLXContext gl_ctx, Window *dummy)
Window win = None;
int cnt;
- cairo_status_t status = CAIRO_STATUS_SUCCESS;
-
/* Create a dummy window created for the target GLX context that we can
* use to query the available GL/GLX extensions.
*/
@@ -114,6 +112,9 @@ _glx_dummy_ctx (Display *dpy, GLXContext gl_ctx, Window *dummy)
vi = glXGetVisualFromFBConfig (dpy, config[0]);
XFree (config);
+ if (unlikely (vi == NULL))
+ return _cairo_error (CAIRO_STATUS_INVALID_FORMAT);
+
cmap = XCreateColormap (dpy,
RootWindow (dpy, vi->screen),
vi->visual,
@@ -136,7 +137,7 @@ _glx_dummy_ctx (Display *dpy, GLXContext gl_ctx, Window *dummy)
}
*dummy = win;
- return status;
+ return CAIRO_STATUS_SUCCESS;
}
cairo_gl_context_t *