Re: How to use GError?



Hi,

Luis Velez <luis hpcf upr edu> writes:

> I am trying to use gdk_pixbuf_save function but this function uses a
> GError as a parameter. So I create the GError and use the
> g_error_new_literal function to give it a domain, code and etc... The
> problem is that even including the glib.h GError gives me the compiling
> error of undeclared. Any help would be a bliss.

you don't need to allocate the GError and actually you shouldn't.
gdk_pixbuf_save() will allocate it for you in case of an error.
You need to write something like this:

{
  GError *error = NULL;

  if (!gdk_pixbuf_save (pixbuf, filename, type, &error))
    {
      g_printerr ("Uhh, couldn't save pixbuf: %\n", error->message);
      g_error_free (error);
      return;
    }

  ...
}

Salut, Sven



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]