|
From: Daniel J S. <dan...@ie...> - 2014-11-16 08:09:19
|
On 11/15/2014 10:09 PM, sfeam wrote:
> On Saturday, 15 November 2014 08:32:38 PM Daniel J Sebald wrote:
>
>> I meant "zombie", not daemon.
>
> I don't see a zombie. The original process really does exit.
>
>> There must be some way of doing this without having to stop/restart a
>
>> thread in the process.
>
> The problem does not depend stop/start of a thread.
>
> It acts the same even if gnuplot is built in single-threaded mode.
>
> The exit+persist procedure is to fork(), leaving a parent and a child.
>
> The parent calls atexit() and exits. The child is supposed
>
> to maintain the plot window. Both the parent and child can
>
> be a single thread. I don't say that this is necessarily the
>
> only possible procedure or the best procedure, but that's the
>
> way it currently works.
The fork idea is OK. (Well, so-so. Remember there's the limitation of
WXT not being an outboard driver.)
I'm wondering about this hunk of code though:
/* (re)start gui loop */
wxTheApp->OnRun();
If I'm understanding correctly, there is some sort of custom event
handling whereby gnuplot manages input events and then shuffles them off
to wxWidgets with the ::SendEvent( wxEvent &event) function. I.e.,
/* wrapper for AddPendingEvent or ProcessEvent */
void wxtApp::SendEvent( wxEvent &event)
{
#ifdef WXT_MULTITHREADED
AddPendingEvent(event);
#else /* !WXT_MULTITHREADED */
ProcessEvent(event);
#endif /* !WXT_MULTITHREADED */
}
Generally, gnuplot is not using wxWidgets event loop (because otherwise
it would be unable to do anything). But then, when gnuplot exits with
persist, it passes event loop processing off to wxWidgets using
wxTheApp->OnRun().
However, that means that even though the wxWidgets objects function
properly (because events are handled by OnRun()) gnuplot can no longer
manage events or in fact do anything. I just confirmed that is the
case. The WXT plot window left behind by persist is basically frozen.
Try right mouse click, or scaling the window and the plot is fragmented.
What's more, the wxWidget events of OnRun() no longer work at that
point either.
This wxApp->OnRun() is sort of a trick to make the WXT terminal seem
persistent, but it isn't persistent in the sense that Qt terminal is, or
X11 terminal is. Gnuplot child process is still running and everything
still available (it's just no longer at the command line). Is there
some way that the core gnuplot event handling can be called instead of
calling wxApp->OnRun()? The right way is the outboard setup, but in
lieu of that might as well make the WXT terminal fully functional when
persistent.
Dan
|