From 81c8cf3e6d839b13e106ab346feaccf1f2f9d3fd Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 26 Oct 2009 11:51:30 +0000 Subject: [PATCH] texture: Error handling fix When cogl_texture_new_from_data() fails in clutter_texture_set_from_data() and no GError is provided, the clutter app will segfault when dereferencing the GError ** and emitting LOAD_FINISHED signal. Based on a patch by: Haakon Sporsheim http://bugzilla.openedhand.com/show_bug.cgi?id=1806 --- clutter/clutter-texture.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c index ab4f99b98..363c99179 100644 --- a/clutter/clutter-texture.c +++ b/clutter/clutter-texture.c @@ -1474,7 +1474,6 @@ clutter_texture_set_from_data (ClutterTexture *texture, /* FIXME if we are not realized, we should store the data * for future use, instead of creating the texture. */ - new_texture = cogl_texture_new_from_data (width, height, flags, source_format, @@ -1484,11 +1483,18 @@ clutter_texture_set_from_data (ClutterTexture *texture, if (G_UNLIKELY (new_texture == COGL_INVALID_HANDLE)) { - g_set_error (error, CLUTTER_TEXTURE_ERROR, + GError *inner_error = NULL; + + g_set_error (&inner_error, CLUTTER_TEXTURE_ERROR, CLUTTER_TEXTURE_ERROR_BAD_FORMAT, "Failed to create COGL texture"); - g_signal_emit (texture, texture_signals[LOAD_FINISHED], 0, *error); + g_signal_emit (texture, texture_signals[LOAD_FINISHED], 0, inner_error); + + if (error != NULL) + g_propagate_error (error, inner_error); + else + g_error_free (inner_error); return FALSE; }