How to check that a matlab.ui.Figure handle is deleted?
There is a waitbar() in my application that shows the progress of a simulation. When an error in the simulation occurs, or when I debug the application, the waitbar windows stay on screen and I have to delete them manually.
I installed a cleanup with
fwaitbar = waitbar(0,’Running simulation of ‘+toml(cname)+’…’);
cleanup = onCleanup(@()killwaitbar(fwaitbar));
…
function killwaitbar(f)
close(f);
end
However, in case there in no error, MATLAB still runs killwaitbar(), and I get the error
Error using close
Invalid figure handle.
Error in R_nests>killwaitbar (line 431)
close(f);
Error in R_nests>@()killwaitbar(fwaitbar) (line 73)
cleanup = onCleanup(@()killwaitbar(fwaitbar));
Error in onCleanup/delete (line 25)
obj.task();
Error in R_nests (line 153)
end
In workspace belonging to R_nests>killwaitbar (line 431)
How can I test for this in the callback? ‘f’ is of class matlab.ui.Figure, but isa(f,’matlab.ui.Figure’) does not say anything about being deleted.
I am sure there is better way to do this but can’t find it.There is a waitbar() in my application that shows the progress of a simulation. When an error in the simulation occurs, or when I debug the application, the waitbar windows stay on screen and I have to delete them manually.
I installed a cleanup with
fwaitbar = waitbar(0,’Running simulation of ‘+toml(cname)+’…’);
cleanup = onCleanup(@()killwaitbar(fwaitbar));
…
function killwaitbar(f)
close(f);
end
However, in case there in no error, MATLAB still runs killwaitbar(), and I get the error
Error using close
Invalid figure handle.
Error in R_nests>killwaitbar (line 431)
close(f);
Error in R_nests>@()killwaitbar(fwaitbar) (line 73)
cleanup = onCleanup(@()killwaitbar(fwaitbar));
Error in onCleanup/delete (line 25)
obj.task();
Error in R_nests (line 153)
end
In workspace belonging to R_nests>killwaitbar (line 431)
How can I test for this in the callback? ‘f’ is of class matlab.ui.Figure, but isa(f,’matlab.ui.Figure’) does not say anything about being deleted.
I am sure there is better way to do this but can’t find it. There is a waitbar() in my application that shows the progress of a simulation. When an error in the simulation occurs, or when I debug the application, the waitbar windows stay on screen and I have to delete them manually.
I installed a cleanup with
fwaitbar = waitbar(0,’Running simulation of ‘+toml(cname)+’…’);
cleanup = onCleanup(@()killwaitbar(fwaitbar));
…
function killwaitbar(f)
close(f);
end
However, in case there in no error, MATLAB still runs killwaitbar(), and I get the error
Error using close
Invalid figure handle.
Error in R_nests>killwaitbar (line 431)
close(f);
Error in R_nests>@()killwaitbar(fwaitbar) (line 73)
cleanup = onCleanup(@()killwaitbar(fwaitbar));
Error in onCleanup/delete (line 25)
obj.task();
Error in R_nests (line 153)
end
In workspace belonging to R_nests>killwaitbar (line 431)
How can I test for this in the callback? ‘f’ is of class matlab.ui.Figure, but isa(f,’matlab.ui.Figure’) does not say anything about being deleted.
I am sure there is better way to do this but can’t find it. waitbar, gui, cleanup, matlab.ui.figure MATLAB Answers — New Questions









