[Cogl] [PATCH 2/2] error: Don't allocate a new CoglError when propagating

Robert Bragg robert at sixbynine.org
Tue Nov 20 04:03:13 PST 2012


On Mon, Nov 19, 2012 at 8:14 PM, Neil Roberts <neil at linux.intel.com> wrote:

> The cogl_error_propagate function takes ownership of the incoming
> error pointer so there's no need to allocate a new error when passing
> it on. The errors can potentially be passed up from a number of layers
> so it seems worthwhile to avoid the allocation.
> ---
>  cogl/cogl-error.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/cogl/cogl-error.c b/cogl/cogl-error.c
> index 4ef3681..50829aa 100644
> --- a/cogl/cogl-error.c
> +++ b/cogl/cogl-error.c
> @@ -104,8 +104,12 @@ _cogl_propagate_error (CoglError **dest,
>  {
>    _COGL_RETURN_IF_FAIL (src != NULL);
>
> -  _cogl_set_error_literal (dest, src->domain, src->code, src->message);
> -  cogl_error_free (src);
> +  if (dest == NULL)
> +    cogl_error_free (src);
> +  else if (*dest)
> +    g_warning (ERROR_OVERWRITTEN_WARNING, src->message);
> +  else
> +    *dest = src;
>  }
>

I think the reason I originally did it the other way was because this api
used to be called _cogl_propogate_gerror() and was intended to propogate an
error e.g. from gdk-pixbuf. Although it's unlikely someone would build cogl
with --without-glib and still use gdk-pixbuf but in that case we shouldn't
just be stealing the message and GError pointers.

I suppose we should either have a clear comment about that for the current
implementation or make _cogl_propogate_gerror() a separate function that
works like the old api and add _cogl_propogate_error() that works as you
suggest.

kind regards,
- Robert

>
>  void
> --
> 1.7.11.3.g3c3efa5
>
> _______________________________________________
> Cogl mailing list
> Cogl at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/cogl
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/cogl/attachments/20121120/6f0d859a/attachment.html>


More information about the Cogl mailing list