Re: XForms: problems with fl_get_choice_text

Steve Lamont (spl@szechuan.ucsd.edu)
Wed, 5 Nov 97 06:19:18 PST

To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> Here is the piece of code that "causes?" the error, or at least the only part
> that uses fl_get_choice_text! It is called every second to update the output-
> field.
>
>
> void redraw()
> {
> sscanf((char *)datum(),"%*s %s %d %s %d",monat,&tag,time_string,&jahr);
> sscanf((char *)time_string,"%d:%d:%d", &stunde_start, &minute_start, &sekund
> e_start);
> monat_int=make_month(monat);
>
> calculate(julian(tag,monat_int,jahr),
> julian(17,12,1997),
> stunde_start, minute_start, sekunde_start,
> 11, 25, 00,
> (char *)fl_get_choice_text(MainForm->dimension_choice),
> (char *)output);
>
> fl_hide_object(MainForm->output_field);
> fl_set_object_label(MainForm->output_field,output);
> fl_show_object(MainForm->output_field);
> alarm(1);
> signal(SIGALRM, redraw);
> }

I suspect the source of your problem is trying to do *anything* other
than set a flag from within a signal handler. Making Xlib calls (or
XForms calls, which are merely sophisticated wrappers around Xlib
calls) is the Kiss of Death[tm]. X is not reentrant and making an X
call from an interrupted X call will cause the sort of bogosity you
experience.

You can do the same thing by either using an idle callback (see
fl_idle_callback() and fl_set_idle_delta()), by using a timeout
(fl_add_timeout()), or by registering a signal handler
(fl_add_signal_callback()).

I list those in more or less my own order of preference. I'd probably
use the idle callback if I had no other idle tasks I needed to perform
in the application.

spl
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
Xforms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/