Callback errors when saving GUI under new name (using GUIDE)
Show older comments
I currently have a GUI that I built using GUIDE that has the desired behavior. I'd like to make major changes, but I want to do them under a different file name. So, in GUIDE, I do file->save as, and save a new file. GUIDE saves a new .fig and generates a new corresponding .m (the only changes from the previous one being that of changing the filename reference in the file.) I've done this before in the past with no issues.
*I'll put a note here that I've looked a quite a few forum Q/A's related to this, but none or the questions or solutions seemed to address my problem.
In this case, when I run the newly generated file (whether I run the .m or hit the green play button the the new .fig), I get an error right away (and I get further errors when I try to use the GUI controls - but I'll focus on the first error for now, since I'm hoping the cause is the same.) The function in which I get the error is as follows:
% --- Executes during object creation, after setting all properties.
function popup_freq_CreateFcn(hObject, eventdata, handles)
% hObject handle to popup_freq (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
%Initialize related values
set(handles.popup_freq,'Value',4);
handles.viewFreq = 'ABC';
guidata(hObject, handles);
The error I get when I run the file is the following:
Struct contents reference from a non-struct array object.
Error in DataViewer2>popup_freq_CreateFcn (line 211)
set(handles.popup_freq,'Value',4);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in DataViewer2 (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)DataViewer2('popup_freq_CreateFcn',hObject,eventdata,guidata(hObject))
If I put a breakpoint in that line and observe the handles variable, I see that it is not a struct, it is simply an empty variable: []. So the error makes sense. However, I do not get this error when I run the original .fig .m pair. If I put a breakpoint at the same line in the same file, then handles is indeed a struct. Doing a text compare on the two .m files, the only difference that shows up is that references (and comments) to "DataViewer1" are changed to "DataViewer2", which is expected.
Any clues? I can put up the whole file if needed - I just didn't want to clutter the post.
Thanks
Accepted Answer
More Answers (0)
Categories
Find more on Historical Contests 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!