wolf@shell.COM (12/04/90)
I recently ran into a very subtle bug that resulted from invoking a callback list as a side-affect of realizing a widget tree. The widget (sub)tree and execution stack are as follows: The Widgets p The 'a' and 'p' widgets are managed. / \ The 'b' widget is unmanaged. / \ a b NOTE: I'm using a dbx-like syntax for specifying a unique procedure. The procedure name `foo`bar reads "the bar class procedure for the foo widget". XtRealizeWidget (p) : XtRealizeWidget calls `p`change_managed BEFORE realizing p. `p`change_managed : Calls p's layout procedure. LayoutP (p) : Computes the layout of its children using the constraint that 'a' is managed while 'b' is unmanaged. Chooses to resize 'a'. XtResizeWidget (a) : Updates a's size and calls its resize procedure. `a`resize : Recomputes its internal state and calls XtCallCallbacks to inform the application. XtCallCallbacks : Calls an application-registered procedure app-callback : Determines that 'b' should be managed as a consequence of a's new state. XtManageChild (b) : Marks 'b' as being managed. DOES NOT CALL the parent's (p) changed_managed procedure because the parent is NOT REALIZED. `p`realize : Realize 'p'. . . . The problem is that LayoutP has already rejected 'b' as being unmanaged and its not reasonable to see if the call to 'XtResizeWidget (a)' managed 'b' as a side-affect. This problem of the parent widget not being updated to reflect the state of its children is not confined to the call 'XtManageChild (b)'. The same affect occurs when 'XtMakeGeometryRequest (b)' is substituted. I fixed my widgets by hacking up `a`resize. Instead of calling XtCallCallbacks it registers a timeout event (0 delay) which calls XtCallCallbacks. Consequently, the call to 'XtRealizeWidget (p)' completes (long) before the call to XtCallCallbacks starts. Any suggestions? I'd like to see a fix in the Intrinsics but realize the difficulty.
etaylor@wilkins.iaims.bcm.tmc.edu (Eric Taylor) (12/06/90)
You need to rethink your mechanism. Once you try to 'Manage' somehting, you should not be calling callbacks that come in and start 'Managing' other things. Xt is just not designed to handle this kind of behavior. -- Eric Taylor Baylor College of Medicine etaylor@wilkins.bcm.tmc.edu (713) 798-3776