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
This commit is contained in:
Florian Müllner 2016-04-14 17:13:17 +02:00
parent 59c2ace98c
commit 63f6ff9151
3 changed files with 50 additions and 11 deletions

View File

@ -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);

View File

@ -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,
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));
&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);
}

View File

@ -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);