Having spent some time pulling my hair out whilst trying to figure out why my reactor callback functions were continuously being evaluated, I believe I have isolated the issue to a possible bug with the
vlr-remove function wherein object reactors are not actually removed by this function.
I have put together the following simple code to demonstrate the issue I am experiencing:
(defun c:addreactor
( / en
) '((:vlr-modified . mycallback))
)
)
)
)
(defun mycallback
( owner reactor params
) (princ "\nCallback Evaluated.") )
Steps to recreate problem:
- Create a circle in the drawing (or any object in fact)
- Run the above program 'addreactor' and click on the created circle
- Move the circle
Now, at this point the circle has been modified and so the reactor callback function will be evaluated, printing the message
'Callback Evaluated' at the command-line.
Within the callback function the calling object reactor is removed using
vlr-remove, and hence the callback function should no longer be evaluated if the circle is modified again.
However, I find the following unexpected result:
Command: _circle Specify center point for circle
or [3P
/2P
/Ttr
(tan tan radius
)]:
Specify radius of circle
or [Diameter
]:
Select object:
Specify base point
or [Displacement
] <Displacement
>:
Specify second point
or <use first point as displacement
>:
Callback Evaluated. ;; <-------------- Callback evaluated as expected, Reactor should now be removed.
#<VLR-Object-Reactor> ;; <-------------- vlr-remove returns Reactor Object, indicating removal is successful
Specify base point
or [Displacement
] <Displacement
>:
Specify second point
or <use first point as displacement
>:
Callback Evaluated. ;; <-------------- Callback still being evaluated even after reactor is removed.
nil ;; <-------------- vlr-remove returning nil as reactor has already been removed.
This is even weirder:
Command: _circle Specify center point for circle
or [3P
/2P
/Ttr
(tan tan radius
)]:
Specify radius of circle
or [Diameter
]:
Select object:
Specify base point
or [Displacement
] <Displacement
>:
Specify second point
or <use first point as displacement
>:
Callback Evaluated. ;; <-------------- Reactor should now be removed.
#<VLR-Object-Reactor> ;; <-------------- vlr-remove returns Reactor object, indicating removal is successful
nil ;; <-------------- Verifying that Reactor has been removed
nil ;; <-------------- Verifying that no Reactors are running
Specify base point
or [Displacement
] <Displacement
>:
Specify second point
or <use first point as displacement
>:
Callback Evaluated. ;; <-------------- Yet callback STILL being evaluated... WTF
nil
Can any of you guys replicate this behaviour? Or maybe spot a mistake in my method?