MATLAB: Does the GUI crash with an “invalid handles” error message after being compiled with MATLAB Compiler 4.0 (R14)

compilecompiledcrashguihandlehandlesinvalidMATLAB Compilerr14stand-alone

I have created a GUI that runs without error in MATLAB. However, if I compile it and then run it in stand-alone mode, triggering a callback may result in the following error:
Invalid handle object.
Error in ==> sample_plot_method at 4
Error in ==> crash_example>pushbutton1_Callback at 87
Error in ==> gui_mainfcn at 75
Error in ==> crash_example at 44
Error while evaluating uicontrol Callback

Best Answer

This bug has been fixed in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
We have verified that there is a bug in MATLAB Compiler 4.0 (R14) in the way that GUIs operate in stand-alone mode.
To work around this issue, try to avoid deletion of handle objects in your code. For example, instead of deleting a figure window and creating a new one for display in a callback function, try updating the axes of a single figure window.