[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Object Widgets



More on Struan's widgets. Sorry for thinking aloud on the group but I find
it all quite interesting.

I have thought of a simple (and in hindsight obvious) solution for the heap
cleanup problem for blocking widgets. Just have the Init method for blocking
widgets always return 0. That way the object exists (in some sense) while
the widget application is running but when the widget application exits it
returns to the Init method, which tells IDL that initialisation was not
successful. Sounds dodgy, but seems to work! So the Init method in Struan's
code becomes (additions in capitals):

function SLFow_minimal::init, BLOCK=BLOCK,  _ref_extra=extra

  if not (self->SLFoWid::init(BLOCK=BLOCK, _extra=extra)) then begin
     print, 'SLFow_minimal: failed to initialise SLFoWid'
     return, 0
  endif

  self.myWidID = widget_base(uvalue=self, title=self.title, /column,
xsize=200)
  temp = widget_button(self.myWidID, value='Undefined')
  self.quitbut = widget_button(self.myWidID, value='Quit')

  widget_control, self.myWidID, /realize

  self -> xmanage

  IF KEYWORD_SET(BLOCK) THEN RETURN, 0 ELSE return, 1

end   ; function SLFow_minimal::init

---
Mark Hadfield
m.hadfield@niwa.cri.nz  http://katipo.niwa.cri.nz/~hadfield/
National Institute for Water and Atmospheric Research
PO Box 14-901, Wellington, New Zealand