From 63f6ff91516bb484fc6de50ecabc791095d81b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 14 Apr 2016 17:13:17 +0200 Subject: [PATCH] Do not skip CoglError parameters While CoglError is a define to GError, it doesn't follow the convention of ignoring errors when NULL is passed, but rather treats the error as fatal :-( That's clearly unwanted for a compositor, so make sure to always pass an error parameter where a runtime error is possible https://bugzilla.gnome.org/show_bug.cgi?id=765061 --- src/st/st-private.c | 9 ++++++++- src/st/st-texture-cache.c | 33 +++++++++++++++++++++++++-------- src/st/st-theme-node-drawing.c | 19 +++++++++++++++++-- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/src/st/st-private.c b/src/st/st-private.c index e5a27019b..b00a2bdd7 100644 --- a/src/st/st-private.c +++ b/src/st/st-private.c @@ -347,6 +347,7 @@ _st_create_shadow_pipeline (StShadow *shadow_spec, { ClutterBackend *backend = clutter_get_default_backend (); CoglContext *ctx = clutter_backend_get_cogl_context (backend); + CoglError *error = NULL; static CoglPipeline *shadow_pipeline_template = NULL; @@ -377,7 +378,13 @@ _st_create_shadow_pipeline (StShadow *shadow_spec, COGL_PIXEL_FORMAT_A_8, rowstride_out, pixels_out, - NULL)); + &error)); + + if (error) + { + g_warning ("Failed to allocate texture: %s", error->message); + cogl_error_free (error); + } g_free (pixels_out); diff --git a/src/st/st-texture-cache.c b/src/st/st-texture-cache.c index cec97d538..1c718acb9 100644 --- a/src/st/st-texture-cache.c +++ b/src/st/st-texture-cache.c @@ -461,14 +461,24 @@ pixbuf_to_cogl_texture (GdkPixbuf *pixbuf) { ClutterBackend *backend = clutter_get_default_backend (); CoglContext *ctx = clutter_backend_get_cogl_context (backend); + CoglError *error = NULL; + CoglTexture2D *texture; - return COGL_TEXTURE (cogl_texture_2d_new_from_data (ctx, - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf), - gdk_pixbuf_get_has_alpha (pixbuf) ? COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGB_888, - gdk_pixbuf_get_rowstride (pixbuf), - gdk_pixbuf_get_pixels (pixbuf), - NULL)); + texture = cogl_texture_2d_new_from_data (ctx, + gdk_pixbuf_get_width (pixbuf), + gdk_pixbuf_get_height (pixbuf), + gdk_pixbuf_get_has_alpha (pixbuf) ? COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGB_888, + gdk_pixbuf_get_rowstride (pixbuf), + gdk_pixbuf_get_pixels (pixbuf), + &error); + + if (error) + { + g_warning ("Failed to allocate texture: %s", error->message); + cogl_error_free (error); + } + + return texture ? COGL_TEXTURE (texture) : NULL; } static cairo_surface_t * @@ -632,6 +642,8 @@ st_texture_cache_reset_texture (StTextureCachePropertyBind *bind, (cairo_image_surface_get_format (surface) == CAIRO_FORMAT_ARGB32 || cairo_image_surface_get_format (surface) == CAIRO_FORMAT_RGB24)) { + CoglError *error = NULL; + texdata = COGL_TEXTURE (cogl_texture_2d_new_from_data (ctx, cairo_image_surface_get_width (surface), cairo_image_surface_get_height (surface), @@ -639,13 +651,18 @@ st_texture_cache_reset_texture (StTextureCachePropertyBind *bind, COGL_PIXEL_FORMAT_BGRA_8888 : COGL_PIXEL_FORMAT_BGR_888, cairo_image_surface_get_stride (surface), cairo_image_surface_get_data (surface), - NULL)); + &error)); if (texdata) { clutter_texture_set_cogl_texture (bind->texture, texdata); cogl_object_unref (texdata); } + else if (error) + { + g_warning ("Failed to allocate texture: %s", error->message); + cogl_error_free (error); + } clutter_actor_set_opacity (CLUTTER_ACTOR (bind->texture), 255); } diff --git a/src/st/st-theme-node-drawing.c b/src/st/st-theme-node-drawing.c index 1f28ed9fd..057b716b4 100644 --- a/src/st/st-theme-node-drawing.c +++ b/src/st/st-theme-node-drawing.c @@ -71,6 +71,7 @@ create_corner_material (StCornerSpec *corner) { ClutterBackend *backend = clutter_get_default_backend (); CoglContext *ctx = clutter_backend_get_cogl_context (backend); + CoglError *error = NULL; CoglHandle texture; cairo_t *cr; cairo_surface_t *surface; @@ -172,7 +173,14 @@ create_corner_material (StCornerSpec *corner) CLUTTER_CAIRO_FORMAT_ARGB32, rowstride, data, - NULL)); + &error)); + + if (error) + { + g_warning ("Failed to allocate texture: %s", error->message); + cogl_error_free (error); + } + g_free (data); g_assert (texture != COGL_INVALID_HANDLE); @@ -958,6 +966,7 @@ st_theme_node_prerender_background (StThemeNode *node, { ClutterBackend *backend = clutter_get_default_backend (); CoglContext *ctx = clutter_backend_get_cogl_context (backend); + CoglError *error = NULL; StBorderImage *border_image; CoglHandle texture; guint radius[4]; @@ -1277,7 +1286,13 @@ st_theme_node_prerender_background (StThemeNode *node, CLUTTER_CAIRO_FORMAT_ARGB32, rowstride, data, - NULL)); + &error)); + + if (error) + { + g_warning ("Failed to allocate texture: %s", error->message); + cogl_error_free (error); + } cairo_destroy (cr); cairo_surface_destroy (surface);