Cannot get rid of "Warning: The class file for 'XXX' has been changed; but the change cannot be applied because objects based on the old class file still exist"

7 visualizaciones (últimos 30 días)
Hi all,
I tried to do 'clear', 'clear all', 'clear classes' etc (as suggested in the warning message itself!). I even embedded my test-code in a try catch:
try
test_code
catch ME
show_error(ME)
clear classes
clear all
end
as an attempt to clear data before leaving my test-function, but nothing helps. It now turns out that I have to restart MATLAB (R2012a) every time an error occurs in one of my classes in order to continue developing. Extremely annoying... Hopefully somebody has a remedy for this...
Best regards,
Jeroen

Respuestas (1)

Tushar Sinha
Tushar Sinha el 5 de Nov. de 2015
Hi Jeroen,
You might be facing this issue as there might be an intermediate instance being created which is not being destroyed. To resolve this issue, make use of a destructor and then delete the object yourself instead of leaving the it to clear function to destroy it.
methods
function delete(obj)
% obj is always scalar
...
end
end
You can destroy handle objects by explicitly calling delete on the object:
delete(obj)
Refer to the link below for more information on Handle Class Destructor: http://www.mathworks.com/help/matlab/matlab_oop/handle-class-destructors.html
Another way to handle this would be to use "clear classes" multiple times in your code
I hope this helps!
Thanks,
Tushar

Categorías

Más información sobre Construct and Work with Object Arrays en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by