[GRASS-dev] set_fatal_error

Martin Landa landa.martin at gmail.com
Mon Jan 14 15:41:26 EST 2008


Hi,

2008/1/14, Martin Landa <landa.martin at gmail.com>:
> Glynn:
> > We already have G_set_error_routine(). However, a fundamental property
> > of G_fatal_error() is that it doesn't return (that's why the "fatal"
> > is part of the name).
>
> right, but it doesn't avoid calling exit(EXIT_FAILURE) in G_fatal_error().
>
> Calling G_fatal_error() causes crashing wxPython GUI e.g. during
> digitization. I am not sure how to handle this, since G_fatal_error()
> is widely used in Vector library. I guess this could be possible to
> solve by using separate thread in Python code(?).
>
> The second point, I guess it was the reason (crashing e.g. qgis) why
> (probably by Radim) Vect_*_fatal_error() were added to Vect library.
> But it is used only in open.c and legal_vname.c as far as i know.
>
> Avoiding calling exit() in G_fatal_error() in the given case would
> make sense, maybe.

I meant something like:

int G_fatal_error (const char *msg,...)
{
    char buffer[2000];  /* No novels to the error logs, OK? */
    va_list ap;

    va_start(ap,msg);
    vsprintf(buffer,msg,ap);
    va_end(ap);

    print_error (buffer,ERR);

    if (ferror == G_FATAL_RETURN) {
	return EXIT_FAILURE;
    }

    exit (EXIT_FAILURE);
}

Martin

-- 
Martin Landa <landa.martin at gmail.com> * http://gama.fsv.cvut.cz/~landa *


More information about the grass-dev mailing list