MATLAB Answers

App does not execute properly unless in debug mode [R2020b]

16 views (last 30 days)
Adam Wisam
Adam Wisam on 10 Apr 2021
Answered: Bruno Luong on 10 Apr 2021
Hello
I have designed an app where the user specifies some input for execution of some functions. I have a button for "run", for which I have created a callback for button pushed. Some of the code is given below. What the code does is first to disable the button so that one cannot accidentally press "run" twice. Then it just checks a website for a license and gives a warning dialog/changes a light color. After that my functions begin, and that part is not problematic so I have omitted it.
What happens is, when I press the "run" button in the app in a non-debug mode, the button is kept enabled, even though the first line in the callback is to disable the button. If I run the exact same code, but put breakpoints and click continue manually, it executes the code properly.
If I'm not connected to the license server (the try catch statement and the following if statement are both executed), the code runs properly and gives me a warning dialog. I can also see that it disables the button, shows the dialog then enables it again (intended).
Now this has happened before in the normal script editor, with some plots. But there I was not sure if there was some code I was not aware of, that may have caused the problem. Here I am pretty sure that there is not anything working other than the code below. Any suggestions?
% Button pushed function: run
function runButtonPushed(app, event)
% This first line is the problematic part
app.run.Enable='off'; % Disable the "run" button
app.vpn.Color=[0,1,0]; % Color of some light, not important
% Check license server, not important
try
stat=webread('http://abaqus.sys.kth.se/v6.14');
catch
app.vpn.Color=[1,0,0];
end
if app.vpn.Color(2)~=1 && contains(app.abqServer.Value,'1')
warndlg('Ingen anslutning till KTH:s VPN','Varning')
app.run.Enable='on';
return
end
% The calculations etc begin here, again no problem here
close all;
fclose('all');
if ~isempty(app.g_Bilder); delete(app.g_Bilder); end
indatafil=string(app.indata.Value);
load(indatafil);

Accepted Answer

Adam Wisam
Adam Wisam on 10 Apr 2021
Answer to the problem for anyone looking:
May be you should add drawnow so as things get refresed
app.run.Enable='off'
drawnow

More Answers (1)

Bruno Luong
Bruno Luong on 10 Apr 2021
May be you should add drawnow so as things get refresed
app.run.Enable='off'
drawnow

Community Treasure Hunt

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

Start Hunting!