Date: Jan 6, 2013 2:54 AM
Author: Nima Nikvand
Subject: Error while evaluating TimerFcn for timer /Invalid or deleted object.

Hello everyone,

I am using a timer in my GUI, and everything seems to be working alright. However after I close my GUI, I am receiving an error, which says:


"Error while evaluating TimerFcn for timer /Invalid or deleted object."

Here is my code for the timer which I run in OpeningFcn:

tmr = timer('Name','Reminder',...
'Period',0.1,... % Update the time every 60 seconds.
'TasksToExecute',inf,... % number of times to update
'ExecutionMode','fixedSpacing',...
'TimerFcn',{@update1,handles});
start(tmr);

and here is the update1:

function update1(hObject,eventdata,handles)
set(handles.text1,'string','');
pause(0.5);
set(handles.text1,'string',num2str(datestr(now)));
set(handles.text1,'Fontsize', 10, 'FontWeight', 'bold');
pause(0.5);


Also, I run a closing function as follows:
set(hObject, 'DeleteFcn', {@closefun,handles});
function closefun(hObject,eventdata,handles)

t = timerfindall;
if ~isempty(t)
stop(t);
delete(t);
clear t;
end
end


But even if I remove the closing function compeletly I still get that error upon closing the GUI. I appreciate any help.