Longstanding bug in ... XtAppMainLoop?

walter harms wharms at bfs.de
Thu Feb 24 06:28:12 PST 2011


this sounds reasonable,
but when do application do not have a display ?

re,
 wh


Am 24.02.2011 00:09, schrieb Jordan Hayes:
> The manual page for XtAppMainLoop says that it's just a simple loop that
> calls
> 
> XEvent event;
> XtAppNextEvent(app, &event);
> XtDispatchEvent(&event);
> 
> ... until XtAppGetExitFlag() returns true.
> 
> And looking at the code in libXt-1.0.9/src/Event.c seems to show that to
> be the case.
> 
> But: XtAppNextEvent() doesn't return until there's an actual XEvent to
> be handled; it handles Xt-internal events (inputs, timers, signals)
> itself, but doesn't return (because of course, those aren't XEvents).
> Which means that the exit flag doesn't get a chance to break the loop
> until/unless there's an actual XEvent.
> 
> If you're not using a Display at all in your app, you lose: timers or
> input sources can't signal the main loop to exit using this mechanism.
> 
> A workaround -- and what I would suggest XtAppMainLoop be fixed to do
> instead -- is code that looks more like this:
> 
>    for (;;) {
>        XtAppProcessEvent(app, XtIMAll);
>        if (XtAppGetExitFlag(app))
>            break;
>    }
> 
> XtAppProcessEvent() returns when *any* event has been dispatched, not
> just ones that involve a Display.  For the source tree, it would look
> something like this:
> 
> void XtAppMainLoop(XtAppContext app) {
>    LOCK_APP(app);
>    do {
>        XtAppProcessEvent(app, XtIMAll);
>    } while (! app->exit_flag);
>    UNLOCK_APP(app);
> }
> 
> I guess I'm the only one who uses Xt this way?
> 
> Thanks,
> 
> /jordan
> _______________________________________________
> xorg at lists.freedesktop.org: X.Org support
> Archives: http://lists.freedesktop.org/archives/xorg
> Info: http://lists.freedesktop.org/mailman/listinfo/xorg
> Your subscription address: wharms at bfs.de
> 



More information about the xorg mailing list