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"
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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
0 Commenti
Risposte (1)
Tushar Sinha
il 5 Nov 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
0 Commenti
Vedere anche
Categorie
Scopri di più su Construct and Work with Object Arrays in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!