multiple instances of gui open at once

Hello,
I created a GUI that asks the user for several parameters before running a model. I give the user the option to save a specific run to use later. I use the hgsave(filename) function. But when the user opens the saved run, 3 instances of the GUI appear.
I can just close 2 of them and the 1 works fine, but I'd really like to stop 3 from appearing before giving the model to my users. Anyone have any ideas? I don't even know where to start debugging this problem. I never had this problem in R2014a but since graphics handles were changed to objects (R2014b or higher), I have duplicates
Thanks

5 commentaires

Adam
Adam le 26 Oct 2015
You'd have to give more details of your code. I have never used hgsave myself but I see nothing in its help to suggest that this would be its normal behaviour so it must be something in your specific code that uses it.
MCM
MCM le 26 Oct 2015
What kind of details? I literally don't know where to start debugging so I'm not sure what details would be useful My code is over 2,000 lines
For saving, the code just prompts user for filename and path (uiputfile) and then goes hgsave
OpeningFcn is pretty standard, it:
  • Sets a bunch of default values in handles
  • chooses default command line output (handles.output=hObject;)
  • updates handles structure (guidata(HObject, handles))
Jan
Jan le 26 Oct 2015
@MCM: It is impossible to guess the reason of your problem based on this information. Anywhere in your code are the commands, which open 3 figures. We cannot guess what "save a specific run" means.
MCM
MCM le 26 Oct 2015
"save a specific run" just means save the current GUI. Aka save all the parameters that the user has entered. Which literally means just save the GUI as it is right now.
The only command that opens the figure is the Opening Fcn function which is standard.
Basically my question is: why when I open something saved using hgsave does it open 3 instances? I never had this problem in R2014a but since graphics handles were changed to objects, I have duplicates
Jan
Jan le 26 Oct 2015
Why do you save the complete GUI? It sound like you want to save the value of the UICONTROLs only. You observe the side-effects and they disturb you. So avoid the side effects by choosing a method, which does not have it: Save the user-defined values of the uicontrols only.

Connectez-vous pour commenter.

Réponses (2)

Jan
Jan le 26 Oct 2015

0 votes

Bold guessing: The problem is inside the code, which is processed for "user opens the saved run". So set a breakpoint there and stept throught your code line by line. You will see, which lines open the unwanted figures.

1 commentaire

MCM
MCM le 26 Oct 2015
My first instinct was to set breakpoints to locate an error inside the code too. So I set a break point in the very first line of the code. The duplicates were created before the break point was initiated. So I set a break point in EVERY subfunction of my code, same thing.

Connectez-vous pour commenter.

MCM
MCM le 26 Oct 2015

0 votes

When I use the Import Data button or double clicked on file (equivalent to load(filename)) the duplicates appear seemingly before my GUI code initiated (see comment about break points).
But when I use hgload(filename) everything opens properly aka only one instance. I have absolutely no idea why. But it works :)

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange

Question posée :

MCM
le 26 Oct 2015

Commenté :

Jan
le 26 Oct 2015

Community Treasure Hunt

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

Start Hunting!

Translated by