Longstanding bug in ... XtAppMainLoop?

walter harms wharms at bfs.de
Thu Feb 24 09:27:30 PST 2011


Hello,
when starting a Xt-Application you should use XtOpenApplication() or XtAppInitialize()
they will call XOpenDisplay().

I read the paper but i am not sure is the programm without display of any use ? or is
it a sample that simply shows the limitation of the model ?
I am not deeply in Xt and have no real clue what that change will bring an benefitz
since the programms i know will terminate if the display will not exists.

re,
 wh


Am 24.02.2011 16:42, schrieb Jordan Hayes:
>> when do application do not have a display ?
> 
> Xt is also a powerful general purpose environment for event-driven
> programming.  Input events, timers, now signals ... all handled pretty
> well.  Originally the big drawback was that XtAppMainLoop would *never*
> return, but this ExitFlag stuff appears to be an attempt to allow it.  I
> also think it should return when there's no chance of ever getting
> another event: if there's no display, no input sources are defined, no
> signals are being watched, and no timers are set.  Someday I'll see if I
> can come up with a patch for that, but in the mean time changing the
> main loop would be a good thing.
> 
> Here's some code that shows the problem:
> 
> #include <X11/Intrinsic.h>
> 
> static void _Tick(XtPointer baton, XtIntervalId* id) {
>    static int count = 0;
> 
>    printf("%d beep!\n", ++count);
> 
>    XtAppContext app = (XtAppContext)baton;
>    if (3 == count)
>        XtAppSetExitFlag(app);
>    else
>        XtAppAddTimeOut(app, 3000, _Tick, app);
> }
> 
> int main(int argc, char** argv) {
>    XtToolkitInitialize();
>    XtAppContext app = XtCreateApplicationContext();
>    XtAppAddTimeOut(app, 3000, _Tick, app);
> 
> #ifdef    SHOWBUG
>    XtAppMainLoop(app);
> #else
>    for (;;) {
>        XtAppProcessEvent(app, XtIMAll);
>        if (XtAppGetExitFlag(app))
>            break;
>    }
> #endif
> 
>    return 0;
> }
> 
> I wrote this paper nearly 20 years ago about it :-)
> 
> http://bitway.com/jordan/papers/USENIX/AppDev.html
> 
> /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