Guide Object Browser Unused Objects

2 views (last 30 days)
Pappu Murthy
Pappu Murthy on 27 Aug 2015
Edited: Pappu Murthy on 2 Sep 2015
I have GUI developed over a period of time and is working fine. In the process I had introduced a few edit boxes and later removed them and deleted the respective callbacks, and creatFcns etc.. Everything is working smoothly now, however, when I look into Object Browser that still shows a number of those edit boxes which are no longer used nor there anywhere in the code. Can I get rid of them from Object Browser?

Answers (2)

Rutuja Shirali
Rutuja Shirali on 31 Aug 2015
I understand that you are still able to view a few edit boxes in the object browser even after you have removed them and their respective callbacks. I tried reproducing this issue on MATLAB R2014b but I was not able to reproduce it. I added a few edit boxes and then removed them and they were no more visible in the object browser.
Make sure that all the references and handles to those edit boxes are removed and you are saving the code after deletion.
  1 Comment
Pappu Murthy
Pappu Murthy on 1 Sep 2015
Not true. They wont ever go away once you create them. In the object browser they are all listed. However, the respective callbacks and their functions can be deleted from the "m" code which I am able to do so. Why the object Browser still shows them, I have no clue.

Sign in to comment.


Walter Roberson
Walter Roberson on 2 Sep 2015
Here is some code to test figures and .fig files to verify the reasonableness of callbacks. All kinds of callbacks are examined and a number of different conditions are potentially reported.
You can use
verifyfig('NameOfFig') %that .fig file specifically
verifyfig() %all current figures
verifyfig(figure(17)) %specific graphics object(s)
and there is an optional second argument for excluding some kinds of object types such as uimenu
Sample output:
>> verifyfig('REPORT1')
Callback problems detected
-> in type "uicontrol" object with id 358.0018310546875 Tag "edit1"
--> in type "figure" object with id 532.000244140625 Tag "figure1"
Suspicious callback "Callback" because anonymous function refers to unfound routine "edit1_Callback"
Suspicious callback "CreateFcn" because anonymous function refers to unfound routine "edit1_CreateFcn"
Note: it is common for GUIDE callbacks to not be found. This version of the code is not able to look inside the .m file corresponding to a .fig file in order to determine whether the routines are there. You will need to look over the outputs carefully as the ones you are looking for will be hidden there. On the other hand if you already know the names from the object browser then this tool will help you to track down where the reference to the object is.
There are some enhancements possible to this code, but I just wrote it to answer this Question.
  1 Comment
Pappu Murthy
Pappu Murthy on 2 Sep 2015
Edited: Pappu Murthy on 2 Sep 2015
I tried your code and all I got was a bunch of errors!
Error using matlab.ui.Figure/horzcat While converting from 'cell': The conversion returned a value of class 'matlab.mixin.Heterogeneous', which cannot be inserted into an array of class 'matlab.ui.Figure'.
Error in verifyfig (line 228) badobjs{numbadobj} = [thisobj, callback_probs{:}]; %will form part of the output

Sign in to comment.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!