home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / windows / openloo / 4567 < prev    next >
Encoding:
Internet Message Format  |  1992-11-18  |  2.0 KB

  1. Path: sparky!uunet!ittc!dscott
  2. From: dscott@schlitz.ittc.wec.com (Dave Scott)
  3. Newsgroups: comp.windows.open-look
  4. Subject: Re: Problem with XV_KEY_DATA
  5. Message-ID: <DSCOTT.92Nov18160537@schlitz.ittc.wec.com>
  6. Date: 18 Nov 92 21:05:37 GMT
  7. References: <102323@bu.edu>
  8. Sender: news@ittc.wec.com
  9. Organization: Westinghouse - Simulators Division, Pittsburgh, PA
  10. Lines: 52
  11. In-reply-to: johnc@murray.bu.edu's message of 17 Nov 92 17:37:08 GMT
  12.  
  13.  
  14. In article <102323@bu.edu> johnc@murray.bu.edu (John Collins) writes:
  15.  
  16. =>I have been writing an application with XView3.  It seems that
  17. =>there is a problem with XV_KEY_DATA.  My application creates a canvas
  18. =>with an XV_KEY_DATA field named CANVAS_XIMAGE_KEY.  A button callback
  19. =>procedure (new_ximage()) changes the CANVAS_XIMAGE_KEY by calling a
  20. =>routine called make_canvas_ximage() (which returns an XImage *).  This
  21. =>is the code
  22.  
  23. =>void
  24. =>new_ximage(item, event)
  25. =>Panel_item item;
  26. =>Event  *event;
  27. =>{
  28. =>   /* First remove the old ximage key. */
  29. =>   xv_set(canvas, XV_KEY_DATA_REMOVE, CANVAS_XIMAGE_KEY);
  30.  
  31. =>   /* Get the new XImage and attach it to the canvas. */
  32. =>   xv_set(canvas, XV_KEY_DATA, CANVAS_XIMAGE_KEY, make_canvas_ximage() );
  33.  
  34. =>   /* redisplay */
  35. =>   ...
  36. =>}
  37.  
  38. =>The wierd thing about this code is that sometimes it goes off without a
  39. =>hitch, and sometimes it makes the program crash.  The crash always happens
  40. =>when the routine make_canvas_ximage returns.
  41.  
  42. Ahhhh!  The key lies in the above statement that it works "sometimes."
  43.  
  44. Try changing the line:
  45.  
  46.   xv_set(canvas, XV_KEY_DATA_REMOVE, CANVAS_XIMAGE_KEY);
  47.  
  48. to:
  49.  
  50.   xv_set(canvas, XV_KEY_DATA_REMOVE, CANVAS_XIMAGE_KEY, NULL);
  51.  
  52. Same change for the other xv_set().
  53.  
  54. The NULL at the end of the xv_set() call will get you every time (er,
  55. well, sometimes :-).
  56.  
  57. Shalom,
  58.  
  59. -dave
  60.  
  61. --
  62.  David A. Scott - das@ils.com   -OR-   dscott@ittc.wec.com (Westinghouse)
  63.  interLogic Software, Inc.             "The shortest distance between
  64.  (Currently on loan to Westinghouse)      two points is under construction."
  65.