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 <haakon.sporsheim@gmail.com>

http://bugzilla.openedhand.com/show_bug.cgi?id=1806
This commit is contained in:
Emmanuele Bassi 2009-10-26 11:51:30 +00:00
parent 00748f6656
commit 81c8cf3e6d

View File

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