フィルターのクリア

corruption of handles and hObject / GUIDE application

2 ビュー (過去 30 日間)
Al
Al 2011 年 6 月 28 日
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?

採用された回答

Al
Al 2011 年 6 月 28 日
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.

その他の回答 (1 件)

Paulo Silva
Paulo Silva 2011 年 6 月 28 日
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');

カテゴリ

Help Center および File ExchangeApp Building についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by