Compiled uitable crashes in standalone application

조회 수: 1 (최근 30일)
Phillip
Phillip 2014년 4월 30일
댓글: Friedrich 2014년 5월 2일
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

답변 (1개)

Sean de Wolski
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
Phillip
Phillip 2014년 5월 2일
Hi Sean
Thanks for the answer. drawnow works fine running the GUI inside matlab itself. However, when I run the compiled GUI exe it freezes indefinitely at the uitable creation point. I'm going to try and create a simplified version of a GUI that replicates this if possible.
So it does seem that there are "differences" between the native and the compiled behaviour?
The pause command does seem to help though. I tested the compiled GUI on two colleagues machines. On the one machine it ran fine, on the other it hanged. I then recompiled with the pause amount doubled and then it ran fine on both machines.
As soon as I have more info, I will post it here.
Regards, Phillip
Friedrich
Friedrich 2014년 5월 2일
Run the application from a console/DOS prompt and see if any errors are thrown.

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

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by