On Wed, 24 Apr 2002, hniksic(a)arsdigita.com wrote:
Jeff Mincy <jeff(a)delphioutpost.com> writes:
> I just spent, oh maybe, 5 minutes looking at the source. I don't
> see how it could do anything other than loop.
>
> It looks like x_IO_error_handler is called, sets
> DEVICE_X_BEING_DELETED (as you stated), then throws to top level,
> which is inside of an infinite for loop.
Yes, but that infinite for loop calls the command loop, doesn't it?
And the command loop should call the event loop, which should execute
the enqueued magic event, which should cause the last available device
getting deleted, which should cause XEmacs to exit gracefully.
Can you see why the magic event doesn't fire or, if it does, why
doesn't XEmacs exit?
> Does it ever exit gracefully?
Deleting the last device should call graceful exit; for example, this
exits:
xemacs -nw -eval "(delete-device (selected-device) t)"
Ok. I spent 10 minutes looking at the code. I now understand the
code twice as much as I did before...
The function x_IO_error_handler enqueues a magic eval delete_device
event. Supposedly, doing this magic event will cause the device to exit.
After event is enqueued, the device is marked as being deleted.
int
x_IO_error_handler (Display *disp)
{
...
if (d)
enqueue_magic_eval_event (io_error_delete_device, dev);
DEVICE_X_BEING_DELETED (d) = 1;
Fthrow (Qtop_level, Qnil);
...
}
Then we go over to handle_magic_event. The first thing that this code
does is checks to see if the frame is being deleted. If it is, magic
event function returns, and does not actually process the event.
Might this be the problem?
static void
emacs_Xt_handle_magic_event (Lisp_Event *emacs_event)
{
/* This function can GC */
XEvent *event = &emacs_event->event.magic.underlying_x_event;
struct frame *f = XFRAME (EVENT_CHANNEL (emacs_event));
if (!FRAME_LIVE_P (f) || DEVICE_X_BEING_DELETED (XDEVICE (FRAME_DEVICE (f))))
return;
switch (event->type)
-jeff