Consider this simple example:
classdef multi_gui properties fig1 fig2 end methods function obj = multi_gui() obj.fig1 = figure('CloseRequestFcn', @obj.closeApp); obj.fig2 = figure('CloseRequestFcn', @obj.closeApp); end function closeApp(obj, hObject, eventdata) delete(obj.fig1) delete(obj.fig2) end end end
It's an app with 2 figures and when one is closed, the other is supposed to be closed as well. However, something is seriously going wrong in the CloseReqeustFcn callback. Using the debugger, I can see that fig1 and fig2 in obj in the callback are "unset", and therefore cannot be closed. What's going on here?
Best Answer