|
From: <tim...@en...> - 2005-06-24 16:44:55
|
Hello ! I keep working on the wxwidgets terminal, and I am now facing a=20 difficult problem. When there are errors on a command line, gnuplot uses its functions=20 int_error(token, string) to inform the user and stop parsing the command=20 line. This function prints an error message and then calls=20 bail_to_command_line() which is simply a wrapper for the standard=20 longjmp(env) function. This is similar to "goto", and puts the program=20 in its initial state by restoring the registers set in main(). As far as I understand, this would be perfect if I had not to use a=20 separate thread for my terminal. Indeed, I want to send a command from=20 the terminal (through a menu for example) to gnuplot. I use events=20 defined in mouse.c, and more precisely a "command" event (which doesn't=20 seem to be used very often, or maybe in OS/2 only). The do_event(event)=20 is executed in my gui thread. When an error appears on the command, we=20 obtain a longjump which is invalid for *this* gui thread... and it ends=20 with a segmentation fault. I can't simply delete the longjump, as it is necessary to stop command=20 line parsing. If I do it, gnuplot either seems to enter in a infinite=20 loop or terminante with an other segfault. Of course, there's a solution : avoid any error in commands sent from my=20 terminal. But it's like reinventing the wheel. (These errors can be=20 various : for example, if I write a dialog to "set xlabel", and the user=20 enters forbidden characters; or I want to send a "replot" while it's the=20 "test" command which has opened the terminal, etc.) Another solution would be to build the terminal as a separate process,=20 like x11 or os/2 ones. But I think it's not an optimal design. So I would be pleased if somebody can give me a tip in order to deal=20 with this issue ;-) . On my side, I will look more thoroughly to existing code to see how=20 things are done (by windows gui, os/2 pm, etc. ) Greetings, Timoth=E9e |