Clear Filters
Clear Filters

corruption of handles and hObject / GUIDE application

2 views (last 30 days)
I have this odd problem within a call back function for a GUI created with 'guide' (this is my first gui app). The handles and hObject variables seem to get corrupted when I call a function (my own function).
case A: This works as expected
function updateButton_Callback(hObject, eventdata, handles)
% hObject handle to updateButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.statusUpdater1,'String','start');
%[retcode,retmsg]=MyFunction('dog', 'cat');
set(handles.statusUpdater1,'String','finish');
Case B: This Doesn't work Same as above with the MyFunction() line uncommented. The console error for the 2nd set is: "??? Error using ==> set Invalid handle object." Also hObject appears to be gone too. I tried copying the two before calling the function and restoring, but that didn't help.
Is there anyway that a function call could kill these locals? Is there a way to re-extract these two directly from the "gui_state" or somewhere else in a"guide" built application/m-file?

Accepted Answer

Al
Al on 28 Jun 2011
Ha! Sorry. It turned out that the MyFunction(), a complicated tree of functions, had a "close all" buried in it (to close all plots). I guess the 'close all' closes, at least partially, the caller's GUI; but the odd thing is that the application GUI doesn't "close" it just doesn't work anymore.

More Answers (1)

Paulo Silva
Paulo Silva on 28 Jun 2011
Try this way:
function updateButton_Callback(hObject, eventdata, handles)
% hObject handle to updateButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
sU1H=handles.statusUpdater1;
set(sU1H,'String','start');
[retcode,retmsg]=MyFunction('dog', 'cat');
set(sU1H,'String','finish');

Categories

Find more on App Building in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!