This looks good to land to me:<div><br></div><div>Reviewed-by: Robert Bragg <<a href="mailto:robert@linux.intel.com">robert@linux.intel.com</a>></div><div><br></div><div>thanks,</div><div>- Robert</div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Thu, Nov 22, 2012 at 5:07 PM, Neil Roberts <span dir="ltr"><<a href="mailto:neil@linux.intel.com" target="_blank">neil@linux.intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The _cogl_propagate_error() function takes ownership of the incoming<br>
<div class="im">error pointer so there's no need to allocate a new error when passing<br>
it on. The errors can potentially be passed up from a number of layers<br>
so it seems worthwhile to avoid the allocation.<br>
<br>
</div>The _cogl_propagate_gerror() function was previously using<br>
_cogl_propagate_error(). Presumably this would not have worked because<br>
that function would try to free the error from glib using<br>
cogl_error_free but that would use the wrong free function and thus<br>
the wrong slice allocator. The GError propagating function is only<br>
used when gdk-pixbuf is enabled which now requires glib support anyway<br>
so we can just avoid defining the function when compiling without<br>
glib.<br>
---<br>
 cogl/cogl-error-private.h |  2 ++<br>
 cogl/cogl-error.c         | 17 ++++++++++++++---<br>
 2 files changed, 16 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/cogl/cogl-error-private.h b/cogl/cogl-error-private.h<br>
index 31b2eab..a886084 100644<br>
--- a/cogl/cogl-error-private.h<br>
+++ b/cogl/cogl-error-private.h<br>
@@ -43,9 +43,11 @@ void<br>
 _cogl_propagate_error (CoglError **dest,<br>
                        CoglError *src);<br>
<br>
+#ifdef COGL_HAS_GLIB_SUPPORT<br>
 void<br>
 _cogl_propagate_gerror (CoglError **dest,<br>
                         GError *src);<br>
+#endif /* COGL_HAS_GLIB_SUPPORT */<br>
<br>
 #define _cogl_clear_error(X) g_clear_error ((GError **)X)<br>
<br>
diff --git a/cogl/cogl-error.c b/cogl/cogl-error.c<br>
index 4ef3681..753e4c8 100644<br>
--- a/cogl/cogl-error.c<br>
+++ b/cogl/cogl-error.c<br>
@@ -104,13 +104,24 @@ _cogl_propagate_error (CoglError **dest,<br>
<div class="im"> {<br>
   _COGL_RETURN_IF_FAIL (src != NULL);<br>
<br>
-  _cogl_set_error_literal (dest, src->domain, src->code, src->message);<br>
-  cogl_error_free (src);<br>
+  if (dest == NULL)<br>
+    cogl_error_free (src);<br>
+  else if (*dest)<br>
+    g_warning (ERROR_OVERWRITTEN_WARNING, src->message);<br>
+  else<br>
+    *dest = src;<br>
 }<br>
<br>
</div>+/* This function is only used from the gdk-pixbuf image backend so it<br>
+ * should only be called if we are using the system GLib. It would be<br>
+ * difficult to get this to work without the system glib because we<br>
+ * would need to somehow call the same g_error_free function that<br>
+ * gdk-pixbuf is using */<br>
+#ifdef COGL_HAS_GLIB_SUPPORT<br>
 void<br>
 _cogl_propagate_gerror (CoglError **dest,<br>
                         GError *src)<br>
 {<br>
-  _cogl_propagate_error (dest, (CoglError *)src);<br>
+  _cogl_propagate_error (dest, (CoglError *) src);<br>
 }<br>
+#endif /* COGL_HAS_GLIB_SUPPORT */<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.11.3.g3c3efa5<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
Cogl mailing list<br>
<a href="mailto:Cogl@lists.freedesktop.org">Cogl@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/cogl" target="_blank">http://lists.freedesktop.org/mailman/listinfo/cogl</a><br>
</div></div></blockquote></div><br></div>