MATLAB: Is the resize function being fired when deleting a surface object in MATLAB 7.0.4 (R14SP2)

callbackdeleteMATLABopenglpaintersrendererresizefcn

I have created a figure window with a ResizeFcn callback. When I delete a surface object in this figure, the ResizeFcn is fired.
f=figure
drawnow
set(f,'resizefcn','disp(''hello'')')
s=surf(peaks)
delete(s)

Best Answer

This is caused because when the surface object is deleted, the renderer is changed back to Painters from OpenGL, which causes the figure to be re-rendered and fires the ResizeFcn callback.
To workaround the issue, clear the ResizeFcn callback before deleting the surface and redeclare it after the surface is deleted or update MATLAB to R2006a or later.