[comp.windows.x.motif] XmText infinite resize problems

nazgul@alphalpha.com (Kee Hinckley) (07/15/90)

A while ago I reported a problem whereby XmText would go into an
infinite loop trying to resize itself.  I even posted (to motif-talk
I believe) a totally bogus patch.  I have finally tracked down the
problem(s?).  I don't know who exactly is at fault here, I kind of
suspect that I am running into two bugs at once, or at least two
"features".  Maybe someone who knows the Intrinsics better can comment.

In the resize code for XmText is a check to see what width actually
got set after it's parent returns XtGeometryYes.  It doesn't compare
this with the old size, but with the size it asked for.  If it turns
out that what it got is not what it asked for, it assumes that
XtGeometryYes actually meant XtGeometryNo.  There's a comment to the
affect that this is to get around bugs in some geometry managers.
What it doesn't notice of course, is that the size may have changed,
just not to what it asked for.  On the other hand, if Yes was returned,
then the size was supposed to be what it asked for, so....

The Table widget (from David Harrison at Berkeley) has an interesting
problem to deal with.  It apparently can't tell for sure whether it can
return GeometryYes without first resizing the widget and trying it.
So the original code simply resized the widget to the requested size,
and then reconfigured itself to fit around it.  This works so long
as it can adjust its size freely.  However if it is constrained, or
possibly under other circumstances, it may end up resizing the widget
again, this time to some other size.  It then returned GeometryDone.

Clearly these two widgets did not get along well.  The bug is evidenced
when XmText has XmNresizeWidth set, although it can occur at other
times as well.

It turns out that I can fix this by modifying the Table widget.
I taught it to return Almost when it can't quite get what was
asked for.  Note however, that it has in this case actually
resized the widget, just not to the intended value.  I can't tell
from a cursory reading of the Intrinsics docs whether this is
legal.  (Any comments?)  Then I put a check in it so that when
it is called it makes sure that the geometry request is not indeed
simply a request to size the widget to the size it already is
(which, in the above case, will be exactly what happens).  In that
case it simply immediately returns GeometryDone.

So, we have three possible error locations; XmText, Table, and me.
Any votes?

						-kee



Alphalpha Software, Inc.	|	motif-request@alphalpha.com
nazgul@alphalpha.com		|-----------------------------------
617/646-7703 (voice/fax)	|	Proline BBS: 617/641-3722

I'm not sure which upsets me more; that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.

-------