Currently qt_waitforinput may be called recursively, if a key is pressed
inside the terminal (e.g. 'l' for logarithmic display), while gnuplot is
waiting for input.
Example backtrace:
#0 in qt_waitforinput (options=1) at qtterminal/qt_term.cpp:839
#1 in check_for_mouse_events () at term.c:3082
#2 in do_line () at command.c:429
#3 in do_string_and_free (cmdline=0x9aa0b0 "set log y") at command.c:454
#4 in do_string (s=0x573b14 "set log y") at command.c:438
#5 in do_string_replot (s=0x573b14 "set log y") at command.c:480
#6 in builtin_toggle_log (ge=0x7fffffffd720) at mouse.c:1062
#7 in event_keypress (ge=0x7fffffffd720, current=true) at mouse.c:1452
#8 in do_event (ge=0x7fffffffd720) at mouse.c:2214
#9 in qt_processTermEvent (event=0x7fffffffd720) at qtterminal/qt_term.cpp:392
#10 in qt_waitforinput (options=0) at qtterminal/qt_term.cpp:902
#11 in getc_wrapper (fp=0x7ffff41c0360 <IO_2_1_stdin>) at readline.c:82
#12 in rl_read_key () from /lib/x86_64-linux-gnu/libreadline.so.6
#13 in readline_internal_char () from /lib/x86_64-linux-gnu/libreadline.so.6
#14 in readline () from /lib/x86_64-linux-gnu/libreadline.so.6
#15 in readline_ipc (prompt=0x56c442 "gnuplot> ") at readline.c:104
#16 in rlgets (s=0x816650 "set log y", n=1024, prompt=0x56c442 "gnuplot> ") at command.c:2714
#17 in gp_get_string (buffer=0x816650 "set log y", len=1024, prompt=0x56c442 "gnuplot> ") at command.c:2910
#18 in read_line (prompt=0x56c442 "gnuplot> ", start=0) at command.c:2942
#19 in com_line () at command.c:310
#20 in main (argc=0, argv=0x7fffffffda58) at plot.c:674
This may cause problems later on, for example if the waitforinput function
is not reentrant. Detect and avoid this problem here.
(Note: this patch works for me, but maybe the problem should be fixed more generally in Gnuplot. I'll also note that I didn't notice any wrong behaviour with the current code, but had problems when trying to port the code to Windows.)
Hmm.
The check_for_mouse_events() path is a recent addition to 4.7, so this particular case of recursion did not exist in released versions of gnuplot. But I don't see in principle why it would be a problem.
The "bind" command always allowed such recursion, although this is probably a rare thing to do intentionally. E.g.
Did you only see this problem with qt, or are other terminals causing an equivalent problem? What exactly was the symptom?
Anyhow, if recursion itself is a problem then this isn't the right fix since it can occur in other contexts than check_for_mouse_events.
Thomas, at first I had some problems with recursion, too. But with the current implementation of
qt_waitforinput
, your patch seems no longer necessary. Could you give the current CVS version a try?Thomas, your patch is included in CVS at the moment. But since the implementation of the Windows variant of qt_waitforinput it does no longer seem to be necessary. It is thus disabled by default. Do you still experience problems which can be resolved by activating this patch?
Sorry for the late response. The project where I embedded Gnuplot on Windows and experienced these problems is finished since end of last year. I'm currently involved in a number of new projects and unfortunately do not have the time to test new gnuplot versions in this environment. From my point of view this bug report can be closed if others have Gnuplot working on Windows.
Thanks for the response and your help to get qt running on Windows.