[comp.windows.x] XmForm, XSync and 0 length timeouts

nazgul@alphalpha.COM (Kee Hinckley) (12/02/90)

First of all, I think there is a bug in form, although I can't be sure,
and I really don't have time to try and duplicate the problem.

I have a Form with two children.  I regularly destroy both children
and create two new kids.  This almost always works.  However
sometimes it stops working, and once it stops working it almost
never works again.  What happens is that it does the destroy fine,
and it creates the new kids, and it manages them.  But they never
show up.  The Form goes blank and nothing ever shows up in it.
Very strange.

However!  I *think* I've fixed the problem (I'm not sure, because
it's one of those things where I can prove it doesn't work, but I
have to use it for ever to prove it does work).  I did this by 
putting an XSync immediately after the destroy.

If anyone has any ideas on what might be going wrong here, please
let me know.  BTW.  I did step through the Form widget once when
it was managing the kids and saw that the Form thought it had 4
kids, not 2.  So it's almost like it didn't get rid of 2 for some reason?
I haven't checked what it looks like when it *is* working though, so
I'm not sure on this.

Now, here comes the second question.  What is the difference between
doing a 0 length timeout and an XSync or XFlush (I'm aware of the
difference between the latter two).  In particular, there are certain
things which only work if you set up a 0 length timeout (like setting
the focus to a particular widget in a dialog box when you're in the
focusCallback).  Would those same things always work if I did an
XSync instead?

					-kee

ben@hpcvlx.cv.hp.com (Benjamin Ellsworth) (12/07/90)

> If anyone has any ideas on what might be going wrong here, please
> let me know.  BTW.  I did step through the Form widget once when
> it was managing the kids and saw that the Form thought it had 4
> kids, not 2.  So it's almost like it didn't get rid of 2 for some
> reason? I haven't checked what it looks like when it *is* working
> though, so I'm not sure on this.

Did you check the core.being_destroyed flag in all four children?  I
believe that 2 of them would have a value of true.  Had you gotten back
to the event loop between destroying the first two and creating the
second two (remember two-phase destroy)?

> Now, here comes the second question.  What is the difference between
> doing a 0 length timeout and an XSync or XFlush (I'm aware of the
> difference between the latter two).  In particular, there are certain
> things which only work if you set up a 0 length timeout (like setting
> the focus to a particular widget in a dialog box when you're in the
> focusCallback).  Would those same things always work if I did an
> XSync instead?

I find your wording a bit ambiguous.  I would restate you as having
said:

	What is the difference between performing an action immediately
	after an XSync or an XFlush, and performing that action as the
	callback from a timeout of 0?

If I have misunderstood, by all means correct me.  To answer the
question that I think you're asking.  The difference is whether or not
XtDispatchEvent has been called or not.  In the first case the
connection is either sync'ed or flushed and the action is run.  In the
second case the timeout has waited until the next call of
XtDispatchEvent, and XtDispatchEvent is not without "side effects" with
respect to timeout-events vs. real X events.

-----------------------------------------------------------------------
Benjamin Ellsworth      | ben@cv.hp.com                | INTERNET
Hewlett-Packard Company | {backbone}!hplabs!hp-pcd!ben | UUCP
1000 N.E. Circle        | (USA) (503) 750-4980         | FAX
Corvallis, OR 97330     | (USA) (503) 757-2000         | VOICE
-----------------------------------------------------------------------
                     All relevant disclaimers apply.
-----------------------------------------------------------------------