[Cogl] [PATCH] atlas: catch _create_texture errors

Robert Bragg robert at sixbynine.org
Mon Nov 19 08:26:49 PST 2012


From: Robert Bragg <robert at linux.intel.com>

Previously we were passing NULL to
cogl_texture_2d_new_{from_bitmap,with_size} so if there was an error the
application would be aborted. This ensures we pass an internal CoglError
so errors can be caught and suppressed instead.
---
 cogl/cogl-atlas.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/cogl/cogl-atlas.c b/cogl/cogl-atlas.c
index 2fe85f0..855fb50 100644
--- a/cogl/cogl-atlas.c
+++ b/cogl/cogl-atlas.c
@@ -279,6 +279,7 @@ _cogl_atlas_create_texture (CoglAtlas *atlas,
                             int height)
 {
   CoglTexture2D *tex;
+  CoglError *ignore_error = NULL;
 
   _COGL_GET_CONTEXT (ctx, NULL);
 
@@ -299,7 +300,7 @@ _cogl_atlas_create_texture (CoglAtlas *atlas,
 
       tex = cogl_texture_2d_new_from_bitmap (clear_bmp,
                                              atlas->texture_format,
-                                             NULL);
+                                             &ignore_error);
       cogl_object_unref (clear_bmp);
 
       g_free (clear_data);
@@ -309,9 +310,12 @@ _cogl_atlas_create_texture (CoglAtlas *atlas,
       tex = cogl_texture_2d_new_with_size (ctx,
                                            width, height,
                                            atlas->texture_format,
-                                           NULL);
+                                           &ignore_error);
     }
 
+  if (!tex)
+    cogl_error_free (ignore_error);
+
   return tex;
 }
 
-- 
1.7.7.6



More information about the Cogl mailing list