MATLAB: Why does UIOPEN opens the GUI two times!

gui guide uiopen twice two times open

To clearify my problem I've used GUIDE to make a simple GUI. I've made two pushbuttons. One to save data using uisave , and one to load data using uiopen. I save the handle variables in a file with the first button. But when I open this file with the second button, it will open my GUI two times!! The code looks like this:
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

uisave('handles');
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
uiopen();
I would really like to open my GUI only one time if I open a file. Or that it just loads the data into the already opened GUI. Looks like I'm doing something very stupid here… (when i just use uisave(); I have the same problem.
Geert

Best Answer

Loading an arbitrary 'handles' structure into a GUI to overwrite that of the GUI is not at all a good thing to do. I cannot think of any situation in which this is a good idea.
If you just want to save data then extract it from handles (if that is where you stored it) and save e.g.
data = handles.data;
uisave( 'data' );
That may not be what is causing your GUI to open twice, but the handles struct is a special struct which contains all the UI components for your GUI so loading it in may well cause the GUI to open again.
Either way, just don't do it! Never replace the handles structure in a callback with a different one!