Paul,
A second one for you to look at.
I have been developing an application, which occasionally fails at run time when updating a number of graphics regions via %pl[external].
In the program below reproduces this failure. There are two %gr regions and two buttons.
The callbacks associated with the buttons generate some random numbers and these are plotted on the %gr regions using %pl[external].
Button 1 always succeeds, button 2 *sometimes” fails, generating a runtime %pl error “too many colours” or crashing with an access violation.
The only difference between the callback functions is that for button 1 the %pl + options are passed as a single string to winio@, while with button 2 winop@ calls are used.
When the access violation occurs in update2_cb, it is always at the first call to winop@ for drawing the second graph, i.e. immediately after iw = select_graphics_object@(uid_gr2)
Ken
module test
use clrwin
implicit none
integer, parameter :: n = 10
real*8 :: x1(10), y1(10), x2(10), y2(10)
integer :: uid_gr1=1001, uid_gr2=1002, gw=600,gh=200
contains
subroutine iface
integer:: iw
iw = winio@('%mn[Exit]&','exit')
iw = winio@('Press buttons sequentially in turn.%nl&')
iw = winio@('Button 1 always succeeds. Button 2 sometimes fails.%nl&')
iw = winio@('Button 2 failure may be a 'too many colours' or access violation.%nl&')
iw = winio@('%2.1ob%`gr&',gw,gh,uid_gr1)
iw = winio@('%ff%`gr%cb&',gw,gh,uid_gr2)
iw = winio@('%^bt[Update 1]&',update1_cb) ! Always works
iw = winio@('%nl%^bt[Update 2]%cb', update2_cb) ! Fails occasionally
end subroutine iface
integer function update1_cb()
integer :: iw
call new_data
! No WINOP@ calls
iw = select_graphics_object@(uid_gr1)
iw = winio@('%pl[n_graphs=1,x_array,symbol=6,colour=red,link=none,external]',n, x1,y1)
iw = select_graphics_object@(uid_gr2)
iw = winio@('%pl[n_graphs=1,x_array,symbol=6,colour=blue,link=none,external]',n, x2,y2)
update1_cb = 1
end function update1_cb
integer function update2_cb()
integer :: iw
call new_data
! With WINOP@ calls
iw = select_graphics_object@(uid_gr1)
call winop@('%pl[n_graphs=1]')
call winop@('%pl[x_array]')
call winop@('%pl[symbol=6,colour=red,link=none]')
iw = winio@('%pl[external]',n, x1,y1)
iw = select_graphics_object@(uid_gr2)
call winop@('%pl[n_graphs=1]') ! Access violation at this line.
call winop@('%pl[x_array]')
call winop@('%pl[symbol=6,colour=blue,link=none]')
iw = winio@('%pl[external]',n, x2,y2)
update2_cb = 2
end function update2_cb
subroutine new_data
call random_number(x1) ; call random_number(y1)
call random_number(x2) ; call random_number(y2)
end subroutine new_data
end module test
program main
use test
call iface
end program main