|
From: Jun T. <tak...@kb...> - 2015-08-31 13:41:17
|
As I wrote before, on my Mac, If I start gnuplot by
$ echo 'set term wxt;plot sin(x);pause mouse close' | gnuplot -d
do something on the wxt plot window (by mouse or keyboard),
go back to the console and hit ^C, then the gnuplot hangs
(actually it is not a hang but an infinite loop with 100% cpu usage).
I haven't tried building a mono-threaded wxt on Linux, but at least
on Mac what happening is the following:
Lines 3870-3872 in wxt_gui.cpp:
yield = 1;
wxTheApp->Yield();
yield = 0;
if ^C is hit during the gui loop Yield(), then the variable yield
remais 1 (the line 'yield = 0' is not executed). After the signal
handler returns, it seems wxt_waitforinput() is called, but
at lines 3852-3853:
if (yield)
return '\0';
so it returns immediately without checking the keyboard input.
This causes that the function do_line() is called repeatedly with
a null string as an input.
The following patch seems to fix this problem, but I'm not confident
that this is the correct fix, and yes, it is rather ugly.
Jun (Jun-ichi Takimoto)
Index: src/wxterminal/wxt_gui.cpp
===================================================================
RCS file: /cvsroot/gnuplot/gnuplot/src/wxterminal/wxt_gui.cpp,v
retrieving revision 1.149
diff -u -r1.149 wxt_gui.cpp
--- src/wxterminal/wxt_gui.cpp 31 Aug 2015 01:47:20 -0000 1.149
+++ src/wxterminal/wxt_gui.cpp 31 Aug 2015 13:26:03 -0000
@@ -2070,11 +2070,17 @@
wxt_sigint_restore();
}
+#if defined(WXT_MONOTHREADED) && !defined(_Windows)
+static int yield = 0; /* used in wxt_waitforinput() */
+#endif
+
void wxt_reset()
{
/* sent when gnuplot exits and when the terminal or the output change.*/
FPRINTF((stderr,"wxt_reset\n"));
+ yield = 0;
+
if (wxt_status == STATUS_UNINITIALIZED)
return;
@@ -3848,7 +3854,6 @@
#else /* !_Windows */
/* Generic hybrid GUI & console message loop */
/* (used mainly on MacOSX - still single threaded) */
- static int yield = 0;
if (yield)
return '\0';
|