Longstanding bug in ... XtAppMainLoop?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

The manual page for XtAppMainLoop says that it's just a simple loop that calls

XEvent event;
XtAppNextEvent(app, &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))

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) {
   do {
       XtAppProcessEvent(app, XtIMAll);
   } while (! app->exit_flag);

I guess I'm the only one who uses Xt this way?


xorg@xxxxxxxxxxxxxxxxxxxxx: X.Org support
Your subscription address: list-xorg@xxxxxxxxxxx

[X Forum]     [Devices]     [XFree86]     [XFree86 Newbie]     [Site Home]     [IETF Annouce]     [Security]     [Fontconfig]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Video for Linux]     [Linux RAID]     [Linux Resources]

Powered by Linux