[comp.windows.x.motif] Widget Creation Library Tip

david@jpl-devvax.JPL.NASA.GOV (David E. Smyth) (07/18/90)

If you are using the Widget Creation Library and it blows up,
especially in something like MatchExactChildren(), MatchWildChildren(),
SearchChildren(), then you have probably compiled the file WcName.c
without setting the cpp macro definition -DMOTIF.

The problem is those pesky Gadgets.  Everything does compile without
the -DMOTIF flag, but the appropriate check to see if a Widget is
really a Gadget is not made, and a core dump will eventually occur.
The core dup does not occur at the point of referencing the garbage,
because Gadgets do have space allocated which covers all the space of a
Widget, but the space is completely different, so the dump occurs
later.

This is both a flame about Gadgets and a warning to programmers using
Motif:  You simply cannot count on a Widget being a Widget.  You very
often need to first check before referencing many of a Widgets core
members.  This is an obvious violation of polymorphism.

I can't figure out why they chose to implement Gadgets _like_this_.  I
can accept the idea of using window-less Widgets if you've got a slow
server (which the HP servers most certainly are NOT).  But dropping
many of the core members, and redefining them so they are garbage if
referenced as core members, ...

The one which trashes XtNameToWidget() is w->core.popup_list 
and w->core.num_popups.

-------------------------------------------------------------------------
David Smyth				david@jpl-devvax.jpl.nasa.gov
Senior Software Engineer,		seismo!cit-vax!jpl-devvax!david
X and Object Guru.			(818)393-0983
Jet Propulsion Lab, M/S 230-103, 4800 Oak Grove Drive, Pasadena, CA 91109
--------------------------- Quote of the Day: ---------------------------
   "A Guru is not one who simply knows all the answers.  Rather, a
    Guru is like one who walks among the mountains, and by wandering
    around abit, can see the horizon through long narrow canyons."
-------------------------------------------------------------------------