[comp.windows.x.motif] XtDestroyWidget & Gadgets

Eric.Rosenquist@CRC2.SKL.DND.CA (10/12/90)

This may well be a candidate for the frequently-asked-questions list,
but since I didn't see an answer in the messages I've collected over
the past few months I'm asking anyway:

I'm having some trouble with XmToggleButtonGadgets.  I put up a simple
dialog that's a couple of nested RowColumn widgets, each of which has
some ToggleButtonGadgets as its children.  All is fine until I try to
destroy the tree via XtDestroyWidget(on the dialog shell), at which
point I get a core dump.  If I use regular XmToggleButton widgets
rather than gadgets everything is fine.  The core dump occurs in the
delayed clean-up activity.

Here's a trace, it's not very instructive to me since we don't have
Motif source (this is on 386/ix with Motif 1.0 by the way):

		Warning: `test' not compiled with -g
		0x19956 in ProcessMenuTree:No lines in file
		*ProcessMenuTree(1,0x447be0,0x446420,1)   [RowColumn.c]
		ProcessMenuTree(0x447be0,0x447be0,0x446420,1)   [RowColumn.c]
		_XmProcessMenuTree(0x447be0,1)   [RowColumn.c]
		ConstraintDestroy(0x447be0)   [RowColumn.c]
		Phase2Destroy(0x447be0)   [Destroy.c]
		Recursive(0x447be0,0x4e6e8)   [Destroy.c]
		Recursive(0x4465f4,0x4e6e8)   [Destroy.c]
		Recursive(0x446420,0x4e6e8)   [Destroy.c]
		Recursive(0x4459d0,0x4e6e8)   [Destroy.c]
		XtPhase2Destroy(0x4459d0,0,0)   [Destroy.c]
		_XtCallCallbacks(0x7ffffe20,0)   [Callback.c]
		XtDispatchEvent(0x7ffffe38)   [Event.c]
		XtAppMainLoop(0x428ddc)   [Event.c]
		XtMainLoop()   [Event.c]
		main(1,0x7ffffed0,0x7ffffed8)   [test.c]

For now I'm assuming that this is just another quirk of gadgets and am
suffering along with the slower non-gadget variety, but I'd like to
know if this is supposed to work or not.

As an aside, I haven't seen any info in the Motif docs regarding the
when's & why's of destroying widgets.  What I've been doing is keeping
dialogs around (just unmanaging them) if there's only one instance of
them and there's a good chance they'll be needed again later.  For
dialogs that can have any number of instantiations, it makes sense to
me to destroy them when they're closed, thereby freeing the memory
they occupy.  Out of curiosity, what are the rest of you doing?

Eric

-- 
Eric.Rosenquist@crc.skl.dnd.ca
Software Kinetics Limited
65 Iber Road, Stittsville, Ontario
Canada - K2S 1E7  Phone (613) 831-0888

nazgul@alphalpha.com (Kee Hinckley) (10/13/90)

> As an aside, I haven't seen any info in the Motif docs regarding the
> when's & why's of destroying widgets.  What I've been doing is keeping

In 1.0 you almost always crash when you destroy widgets.  Much
better to just unmange (or for dialogs, unmap) them and reuse
them later.  Even if you don't crash you'll probably leak memory
like crazy.  In all fairness this isn't completely Motif's fault, there
are lots of problems in the Intrinsics as well.

In 1.1, with patchlevel 16 or so of Xt, things are much better.
There seem to be no major leaks on deletion (I've seen some
when I override translations in my program, but I think it's an
Intrinsics bug and I haven't had time to track it down for sure).
There are a couple places where Motif is referencing just
deleted widgets but those are rarely fatal and should be fixed
in 1.1.1.

However.  I don't know how fast your machines are, but
caching windows and even dialogs can make huge differences
in speed, so even without leaks and bugs I think it's well
worth it if you can.

A side question here.  Is there anyone on the motif list who
is using 1.1 and isn't a OSF support customer (and thus
on motif-talk)?  I've been assuming it hasn't filtered out
into binary-only form yet, but I could be wrong.