Delete uiprogress object at the end of startup function
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Bereketab Gulai
el 14 de Abr. de 2020
Comentada: Bereketab Gulai
el 16 de Abr. de 2020
Hello,
It seems that MATLAB is not deleting the uiprogress object variable when startup function in App Designer apps ends execution.
- Does it behave differently for some local variables? I do now delete or close (pBar), but why bother when it is local variable?
function startupFcn(app)
pBar = Utility.showIndeterminateBar(app.UIFigure);
%.....
end
%... Still runs....
UPDATE 1
I tested a separate app, and it the correct behaviour operated but not with actual. Though I have tested it with above code, removed the Utility function so that you can test...though there is nothing...
UPDATE 2
Tested with onCleanup, the result is the same...I can conclude that this has to do with MATLAB not clearing the startupFcn on time/immediately...The question would be; is there anything that can be done to prevent this?
function onCleanUpTask = showIndeterminateBar(uifigObj)
uiprogbar = uiprogressdlg(uifigObj,'Title','Please Wait...',"Indeterminate","on");
onCleanUpTask = onCleanup(@()delete(uiprogbar));
end
For your full knowledge I do have:
app.onCleanupArray{1} = onCleanup(@()cleanUpTasks(ParamNumberIn));
ParamNumberIn is a param variable local to startupFcn which will be deleted when the UIFigure is deleted. Which maybe the cause that MATLAB is saving the WORKSPACE for that function because this referenced local variable?
6 comentarios
Adam Danz
el 14 de Abr. de 2020
Editada: Adam Danz
el 14 de Abr. de 2020
I assumed that the progress bar you're describing is produced in Utility.showIndeterminateBar (based on the variable name and that it's called from the startupFcn) but I don't know what that function is.
AppDesigner doesn't show a progress bar when opening the app unless you've programmed one, so the source of the progress bar is unclear.
When opening the app for editing, a progress bar is shown (example below). Is this was you're referring to?
Respuesta aceptada
Adam Danz
el 14 de Abr. de 2020
The uiprogressdlg outputs a handle to the progress bar. To delete the bar,
d = uiprogressdlg(h);
delete(d)
to reset it to 0,
d.Value = 0;
If it works when you use the uiprogressbar directly but it doesn't work when you use your wrapper function, my guess is that you're not providing the correct handle to the uiprogressbar in the output.
When you try to delete it, is there an error?
If the problem persists, please provide the entire wrapper function so we can see what's going on and share any error messages in their entirety.
3 comentarios
Adam Danz
el 15 de Abr. de 2020
Why not just run uiprogressdlg independently? Why wrap it in another function?
I suggest the following:
1) Set the uiprogbar handle as a private property of your app. To do so, follow step #2 described here.
2) In your startup function, call uiprogressdlg directly. The handle to the progress bar will be stored in the app variable and will be accessible from anywhere within the app where the app variable is accessed.
app.uiprogbar = uiprogressdlg(uifigObj,'Title','Please Wait...',"Indeterminate","on");
3) whenever you want to delete the progress bar,
delete(app.uiprogbar)
Más respuestas (0)
Ver también
Categorías
Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!