Re: Simple GDK app segfaults for unknown reason
- From: Gyözö Both <gyboth bygfoot com>
- To: László Monda <mondalaci gmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Simple GDK app segfaults for unknown reason
- Date: Fri, 20 Jan 2006 18:24:19 +0100
hi,
i'd say you forgot to end the call with a NULL. also, as far as i know
the standard way to use GError is to have a 'GError *error;' variable
and then pass the pointer to it. in your case:
GError *error = NULL;
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file("input.jpg", &error);
gdk_pixbuf_save(pixbuf, "output.bmp", "bmp", &error, NULL);
but of course it doesn't make sense to use GError if you don't look at
the error variable afterwards; e.g. to display the error message if
there was an error and free the error variable with g_error_free. i use
in my projects a function to check GErrors (called every time i used a
function that i passed a GError to):
/**
Print the contents of a GError (if it was set).
If abort_program is TRUE, we free the memory
and exit the game.
@param error The GError we check.
@param abort_program Whether or not we continue or exit the program.
*/
void
misc_print_error(GError **error, gboolean abort_program)
{
if(*error == NULL)
return;
g_warning("error message: %s\n", (*error)->message);
g_error_free(*error);
*error = NULL;
if(abort_program)
main_exit_program(EXIT_PRINT_ERROR, NULL);
}
i hope i could help.
gyozo
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]