Google
  Web www.spinics.net

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);
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@xxxxxxxxxxxxxxxxxxxxx: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.freedesktop.org/mailman/listinfo/xorg
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