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"
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Tushar Sinha
2015-11-5
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Construct and Work with Object Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!