leap variables and widgets [message #39151] |
Tue, 20 April 2004 08:14 |
Olivier_Gasnault
Messages: 2 Registered: April 2004
|
Junior Member |
|
|
Could anyone point out what goes wrong in the set of codes below.
Run the widget1 procedure and click twice on the button.
The program stops then.
At this stage pvar is not a valid pointer, while it should !
Why ?
If you comment the ptr_free command then the problem disappear...
But I do not understand why the ptr_free would be executed before the
end of the widget2 procedure.
;---
pro widget2_event, ev
common pointer, pvar
WIDGET_CONTROL, ev.id, get_uvalue=uval
if uval eq 'BUTTON2' then stop
end
;---
pro widget2
common pointer, pvar
base2 = WIDGET_BASE(title='widget2')
button2 = WIDGET_BUTTON(base2, uvalue='BUTTON2')
WIDGET_CONTROL, base2, /REALIZE
XMANAGER, 'Widget2', base2
end
;---
function main_widget2
common pointer, pvar
struct_pvar = {hello:'hello'}
pvar = ptr_new(struct_pvar, /NO_COPY)
widget2
ptr_free, pvar
end
;---
pro widget1_event, ev
WIDGET_CONTROL, ev.id, get_uvalue=uval
if uval eq 'BUTTON1' then f = main_widget2()
end
;---
pro widget1
base1 = WIDGET_BASE(title='widget1')
button1 = WIDGET_BUTTON(base1, uvalue='BUTTON1')
WIDGET_CONTROL, base1, /REALIZE
XMANAGER, 'Widget1', base1
end
|
|
|