Re: How to cleanup an object with a non-modal widget method [message #88077 is a reply to message #88073] |
Tue, 18 March 2014 20:03   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
wlandsman writes:
>
> Mathew, David -- thanks for the suggestions. Sorry if this post appears twice -- Google groups is driving me crazy.
>
> On Monday, March 17, 2014 6:02:00 PM UTC-4, Matthew Argall wrote:
>> A simple solution would be to turn "displaymap" into a function so that you can return your oAstroMap object reference. Then, when you are done with it, you can destroy it.
>
> I am trying to write a wrapper for non-IDL users. I want them to be able to type "displaymap" at the IDL prompt and view and manipulate the widget, without them needing to perform any additional cleanup after they click the widget QUIT button.
>>
>> Maybe more to what you are looking for, check out the TLB_KILL_REQUEST_EVENTS and KILL_NOTIFY keyword to the Widget_Base function. You can have the callback routines kill the object when the top level base is destroyed.
>
> I'll look more closely at these but it still looks like the object has to destroy itself (and not just the widget), and I haven't had much luck with OBJ_DESTROY, self. Perhaps I need to also write the wrapper as an object.
>>
>> I have another, more complicated solution if neither of these work for you... Is AstroMap object based on function/object graphics? Or is it made from the old widgets?
>
> No, it uses "classic" widgets with Coyote graphics. --Wayne
I guess I still don't understand the problem. The object is created in
association with a widget program, right? The widget program can
(probably does) have a CLEANUP routine that is called when the widget
dies. All you have to do is find a way to put the object reference into
the info structure of the widget. Then, when the widget dies, you get
the info structure, find the object reference, and destroy that. There
is no "self" there. Just the object reference in a widget CLEANUP
routine. I can't imagine how this could cause problems.
PRO Widget_Cleanup, tlb
Widget_Control, tlb, Get_UValue=info
Obj_Destroy, info.objectRef
END
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|