Compiled uitable crashes in standalone application

1 view (last 30 days)
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

Answers (1)

Sean de Wolski
Sean de Wolski on 1 May 2014
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 Comments
Phillip
Phillip on 2 May 2014
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 on 2 May 2014
Run the application from a console/DOS prompt and see if any errors are thrown.

Sign in to comment.

Categories

Find more on Environment and Settings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!