Erroneous buttons created in AppDesigner

I have an App created in AppDesigner that keeps creating five copies of the same button whenever I open the app. After deleting and/or resaving the entries in AppDesigner, the same buttons are recreated when I open the app again.
I have edited this app on both Windows and Mac, in 2017B, 2020B and 2021A. I am seeing this issue currently on Windows 2021A, but believe I also saw it on Mac 2021A. I would ideally like to keep functionality across all versions and operating systems, but understand if this is causing the issue.
I cannot easily create a minimal example, but will try if it would be helpful.

댓글 수: 5

Image Analyst
Image Analyst 2021년 9월 22일
What are the buttons called? When you save the new UI in App Designer, are there callbacks for those buttons still in the source code?
Are the buttons created upon launching App Designer, or at run time? Is they're created at run time, do you have any calls to the uibutton() or uicontrol() functions anywhere in your code that might create additional buttons?
Jeremiah Sullivan
Jeremiah Sullivan 2021년 9월 22일
편집: Jeremiah Sullivan 2021년 9월 22일
Let me know if I miss anything
  • Button is named "RefreshButton_2". I can rename and delete all occurances of the button and the auto-generated code updates appropriately (no reference to RefreshButton_2 remains).
  • Callbacks: No, if I delete all of the buttons there are no matches for "RefreshButton_2" anywhere in the code (callback or otherwise); at least the code exposed in "Code View"
  • Launching vs. Runtime: I hypothesize they are created when I open the app (`>> appDesigner(filename)`)
  • If I just open and close the app, it prompts me to save (file was modified), leading me to believe the app was properly saved
  • I can run the app just fine after I delete the buttons, so I don't think anything bad is happening at runtime
  • There are no calls to uibutton outside of the automatically generated (uneditable) code. There are no calls to uicontrol
It seems like the number of buttons each iteration created has increased the more I play with it. Here is what the auto-generated properties look like now (I renamed one of the original buttons to RefreshButtonAgain, which is not duplicating itself).
RefreshButton_2 matlab.ui.control.Button
RefreshButton_2 matlab.ui.control.Button
RefreshButton_2 matlab.ui.control.Button
RefreshButton_2 matlab.ui.control.Button
RefreshButton_2 matlab.ui.control.Button
RefreshButton_2 matlab.ui.control.Button
RefreshButton_2 matlab.ui.control.Button
RefreshButton_2 matlab.ui.control.Button
RefreshButton_2 matlab.ui.control.Button
RefreshButton_2 matlab.ui.control.Button
RefreshButton_2 matlab.ui.control.Button
RefreshButton_2 matlab.ui.control.Button
RefreshButton_2 matlab.ui.control.Button
RefreshButton_2 matlab.ui.control.Button
RefreshButton_2 matlab.ui.control.Button
RefreshButton_2 matlab.ui.control.Button
RefreshButton_2 matlab.ui.control.Button
RefreshButton_2 matlab.ui.control.Button
RefreshButton_2 matlab.ui.control.Button
RefreshButton_2 matlab.ui.control.Button
RefreshButtonAgain matlab.ui.control.Button
Here is the auto-generated creation code. The callback-behavior is a bit strange (not every button has a callback)
Edit: it shares the "RefreshButtonPushed" callback with another button, not sure why that would be an issue though
% Create RefreshButtonAgain
app.RefreshButtonAgain = uibutton(app.DataFiltersPanel, 'push');
app.RefreshButtonAgain.Position = [12 11 57 28];
app.RefreshButtonAgain.Text = 'Refresh';
% Create RefreshButton_2
app.RefreshButton_2 = uibutton(app.DataFiltersPanel, 'push');
app.RefreshButton_2.Position = [12 11 57 28];
app.RefreshButton_2.Text = 'Refresh';
% Create RefreshButton_2
app.RefreshButton_2 = uibutton(app.DataFiltersPanel, 'push');
app.RefreshButton_2.ButtonPushedFcn = createCallbackFcn(app, @RefreshButtonPushed, true);
app.RefreshButton_2.Position = [12 11 57 28];
app.RefreshButton_2.Text = 'Refresh';
% Create RefreshButton_2
app.RefreshButton_2 = uibutton(app.DataFiltersPanel, 'push');
app.RefreshButton_2.Position = [12 11 57 28];
app.RefreshButton_2.Text = 'Refresh';
% Create RefreshButton_2
app.RefreshButton_2 = uibutton(app.DataFiltersPanel, 'push');
app.RefreshButton_2.ButtonPushedFcn = createCallbackFcn(app, @RefreshButtonPushed, true);
app.RefreshButton_2.Position = [12 11 57 28];
app.RefreshButton_2.Text = 'Refresh';
% Create RefreshButton_2
app.RefreshButton_2 = uibutton(app.DataFiltersPanel, 'push');
app.RefreshButton_2.Position = [12 11 57 28];
app.RefreshButton_2.Text = 'Refresh';
% Create RefreshButton_2
app.RefreshButton_2 = uibutton(app.DataFiltersPanel, 'push');
app.RefreshButton_2.Position = [12 11 57 28];
app.RefreshButton_2.Text = 'Refresh';
% Create RefreshButton_2
app.RefreshButton_2 = uibutton(app.DataFiltersPanel, 'push');
app.RefreshButton_2.ButtonPushedFcn = createCallbackFcn(app, @RefreshButtonPushed, true);
app.RefreshButton_2.Position = [12 11 57 28];
app.RefreshButton_2.Text = 'Refresh';
% Create RefreshButton_2
app.RefreshButton_2 = uibutton(app.DataFiltersPanel, 'push');
app.RefreshButton_2.Position = [12 11 57 28];
app.RefreshButton_2.Text = 'Refresh';
% Create RefreshButton_2
app.RefreshButton_2 = uibutton(app.DataFiltersPanel, 'push');
app.RefreshButton_2.ButtonPushedFcn = createCallbackFcn(app, @RefreshButtonPushed, true);
app.RefreshButton_2.Position = [12 11 57 28];
app.RefreshButton_2.Text = 'Refresh';
% Create RefreshButton_2
app.RefreshButton_2 = uibutton(app.DataFiltersPanel, 'push');
app.RefreshButton_2.Position = [12 11 57 28];
app.RefreshButton_2.Text = 'Refresh';
% Create RefreshButton_2
app.RefreshButton_2 = uibutton(app.DataFiltersPanel, 'push');
app.RefreshButton_2.Position = [12 11 57 28];
app.RefreshButton_2.Text = 'Refresh';
% Create RefreshButton_2
app.RefreshButton_2 = uibutton(app.DataFiltersPanel, 'push');
app.RefreshButton_2.ButtonPushedFcn = createCallbackFcn(app, @RefreshButtonPushed, true);
app.RefreshButton_2.Position = [12 11 57 28];
app.RefreshButton_2.Text = 'Refresh';
% Create RefreshButton_2
app.RefreshButton_2 = uibutton(app.DataFiltersPanel, 'push');
app.RefreshButton_2.Position = [12 11 57 28];
app.RefreshButton_2.Text = 'Refresh';
% Create RefreshButton_2
app.RefreshButton_2 = uibutton(app.DataFiltersPanel, 'push');
app.RefreshButton_2.ButtonPushedFcn = createCallbackFcn(app, @RefreshButtonPushed, true);
app.RefreshButton_2.Position = [12 11 57 28];
app.RefreshButton_2.Text = 'Refresh';
% Create RefreshButton_2
app.RefreshButton_2 = uibutton(app.DataFiltersPanel, 'push');
app.RefreshButton_2.Position = [12 11 57 28];
app.RefreshButton_2.Text = 'Refresh';
% Create RefreshButton_2
app.RefreshButton_2 = uibutton(app.DataFiltersPanel, 'push');
app.RefreshButton_2.Position = [12 11 57 28];
app.RefreshButton_2.Text = 'Refresh';
% Create RefreshButton_2
app.RefreshButton_2 = uibutton(app.DataFiltersPanel, 'push');
app.RefreshButton_2.ButtonPushedFcn = createCallbackFcn(app, @RefreshButtonPushed, true);
app.RefreshButton_2.Position = [12 11 57 28];
app.RefreshButton_2.Text = 'Refresh';
% Create RefreshButton_2
app.RefreshButton_2 = uibutton(app.DataFiltersPanel, 'push');
app.RefreshButton_2.Position = [12 11 57 28];
app.RefreshButton_2.Text = 'Refresh';
% Create RefreshButton_2
app.RefreshButton_2 = uibutton(app.DataFiltersPanel, 'push');
app.RefreshButton_2.ButtonPushedFcn = createCallbackFcn(app, @RefreshButtonPushed, true);
app.RefreshButton_2.Position = [12 11 57 28];
app.RefreshButton_2.Text = 'Refresh';
% Create RefreshButton_2
app.RefreshButton_2 = uibutton(app.DataFiltersPanel, 'push');
app.RefreshButton_2.Position = [12 11 57 28];
app.RefreshButton_2.Text = 'Refresh';
I had a similar problem, but with EditFieldLabels rather than a button. Eventually, I got sick of it and deleted all version of the labels being duplicated, an option which is more convenient when it's just a label.
I never did find a better, and my problem did not seem to multiply as yours does
Adam Danz
Adam Danz 2021년 9월 29일
편집: Adam Danz 2024년 6월 28일
Contact tech support. In a previous question, tech support provided a function to the user that solved the problem.
Kostas Pitrhs
Kostas Pitrhs 2024년 6월 27일
I have the exact problem now in 2024a!

댓글을 달려면 로그인하십시오.

답변 (1개)

Reshma Nerella
Reshma Nerella 2022년 2월 2일

0 개 추천

Hi,
This bug was fixed in R2018b Update 3.
This issue might still be seen in future releases of MATLAB while editing the apps that were are created in any version before R2018b Update 3.
In your case, instead of editing the app in R2020b or R2021a, create a new one to prevent the issue.

댓글 수: 1

Kostas Pitrhs
Kostas Pitrhs 2024년 6월 27일
How was this bug fixed if it appears in 2021!!!
And by the way, I now have the xact same issue in 2024 a!!!!

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

릴리스

R2021a

태그

질문:

2021년 9월 22일

편집:

2024년 6월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by