home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / amiga / programm / 11441 < prev    next >
Encoding:
Internet Message Format  |  1992-07-21  |  1.9 KB

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