home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!henson!news.u.washington.edu!milton.u.washington.edu!cooper
- From: cooper@milton.u.washington.edu (Ken Cooper)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Bug in CreateGadget().....
- Message-ID: <1992Jul21.175648.25836@u.washington.edu>
- Date: 21 Jul 92 17:56:48 GMT
- Article-I.D.: u.1992Jul21.175648.25836
- Sender: news@u.washington.edu (USENET News System)
- Reply-To: cooper@u.washington.edu
- Organization: University of Washington, Seattle
- Lines: 27
-
-
- While doing some programming last night I ran across a bug in the
- CreateGadget() routine dealing with string gadgets. I was using an
- INTEGER_KIND gadget with the font (TextAttr) set to LetterGothic 30 point that
- I had opened earlier in the program. The problem was encountered when I
- attempted to use CreateGadget() with the new font and had the gadget height
- too small to render the font in. Although the RKM Libraries chapter on Gadgets
- states that the default system font will be used in this case, the
- CreateGadget() call returned a NULL pointer (indicating failure) instead of
- a gadget structure pointer. That's fine, since my gadget height was too small.
- The 'BUG' however, came when my code responded to the NULL return value by
- attempting to free up everything and quit gracefully. It seems that even
- though the CreateGadget() routine and 'failed' and returned a NULL pointer, it
- had already linked in the 'new' Gadget structure onto the end of my gadget
- list. In fact, it had done this linkage and then failed prior to initializing
- the NextGadget field of the 'new' Gadget structure to NULL. As a result,
- when I went and did FreeGadget(glist) my machine went out to lunch.
- Anyway, the obvious solution for me was to correct the hieght of my gadget.
- HOWEVER, IF CreateGadget() IS GOING TO FAIL AND RETURN A NULL, IT SHOULD NOT
- LEAVE THE GADGET LIST LINKAGE CORRUPTED.
-
- For your info......
-
- Ken Cooper
- Applied Physics Laboratory
- University of Washington
- cooper@u.washington.edu
-