Compiled uitable crashes in standalone application
3 次查看(过去 30 天)
显示 更早的评论
Hi,
I have created a programmatic GUI which I compile into a stand-alone application. When I run it from Matlab every thing works fine. I compile the GUI and it compiles and packages fine.
When I run the actual .exe it works fine until just before the end of the code where it creates a uitable. The application then hangs. From outputting to a log file I know that it's hanging at the uitable creation line:
t = uitable('Data',cellData,'ColumnName',{'Col1','Col2'});
I did research on this and from my limited understanding it seems to be that matlab "outsources" this to Java Event Dispatcher. Matlab then carries on and things go out of sync causing the application to hang indefinitely.
The solution is apparently to issue a drawnow and/or pause(someSmallTime) command. Playing around with this I had to do the following:
drawnow;
t = uitable('Data',cellData,'ColumnName',{'Col1','Col2'});
drawnow;pause(0.1);drawnow;
This does work but if the deployed machine is slow or busy with other stuff the 0.1 secs might not be enough. It just doesn't seem the correct way to do things.
This application is going to be a complex GUI in the end with lots of sub GUIs etc.
I would like to know if there is a better solution for this or if my design is wrong. Basically what can I do to make sure I don't need to worry about all the graphics updating/flushing before I invest to heavily in this GUI.
Regards, Phillip
0 个评论
回答(1 个)
Sean de Wolski
2014-5-1
Use a drawnow as you have. This will flush the event queue which will force MATLAB to hold until this happens regardless of how slow the computer is.
pause() is only useful because it implicitly calls drawnow, not because of the pause amount.
2 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!