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

Re: Error on shutdown of widget !@$%



Sean Heukels wrote:
> 
> How do I get rid off, or catch this error ??
> 
> When I shutdown my widget program by clciking exit, in my menubar, I can
> reset colors, structures, the whole thing.
> But when I click the Top-right-cross (Windows) And top-left=box on Unix,
> which shutsdown the current process, I get an error by widget_event,
> that this one ('named by number') is not defined.
> 
> I wish to clean up the variables that I clean on pushing exit in the same
> way and dont want 2 create errors.
> 
> How can this be done ??
> 
> Thnks Sean

The problem here is, that when you kill the widget by the
window-manager,
your widget doesn't exist anymore when you want to read data from it.
You can define a procedure for the top level base via the KILL_NOTIFY
keyword
which will be called when the widget dies, no matter how.
This procedure gets the widget ID of the dying widget as an argument.
Alternatively you define a cleanup procedure via the CLEANUP keyword to
xmanager,
which overrides the KILL_NOTIFY. It also gets the widget ID as its
argument.
Do the cleanup in one of these procedures and just kill the widget in
the
event handler (the cleanup routine will be called then also.

Cheers,
marc

Example:

pro testKill,ID
print,'testKill'
print,widget_info(/VALID_ID,ID)
end

pro xKill,ID
print,'xKill'
print,widget_info(/VALID_ID,ID)
end

pro test_Event,event
widget_control,event.top,/DESTROY
end

pro test

tlb=widget_base(/COL,KILL_NOTIFY='testKill')

wb=widget_button(tlb,VALUE='--------------OK------------')

widget_control,tlb,/REALIZE

;; uncomment the CLEANUP keyword for using xKill instead
xmanager,'test',tlb;,CLEANUP='xKill'
end