Why is a segmentation violation produced when I set a uicontrol's Callback to a cell array containing empty matrices in MATLAB?

1 view (last 30 days)
I use something similar to the following code:
u = uicontrol('Style','popupmenu','String',{'one';'two';'three'})
cb = cell(1);
set(u,'Callback',cb)
When I run this code, MATLAB produces a segmentation violation:
----------
Segmentation violation detected at Tue Mar 25 11:01:35 2003
----------
Configuration:
MATLAB Version: 6.5.0.180913a (R13)
Operating System: Microsoft Windows 2000
Window System:Version 5.0 (Build 2195: Service Pack 3)
Processor ID: x86 Family 15 Model 2 Stepping 4, GenuineIntel
Virtual Machine:Java 1.3.1_01 with Sun Microsystems Inc. Java HotSpot(TM) Client VM
(mixed mode)
Register State:
EAX = 00000000EBX = 00000000
ECX = 2fd56e44EDX = 00000000
ESI = 2fdba6b8EDI = 2fd5a078
EBP = 00dfc3dcESP = 00dfc3c0
EIP = 7a5778aaFLG = 00010206
Stack Trace:
[0] gui.dll:public: __thiscall MCallback::MCallback(struct mxArray_tag const *)(0x2fd5a078, 2, 0x2fc7a160, 0) + 170 bytes
[1] gui.dll:_MatrixToMCallback(0x2fd56e20, 0x2fdbb0e0, 0x2fc7a160, 0x00dfc464) + 73 bytes
[2] hg.dll:_Matrix_to_MCallback_set_check_fcn(0x2fd56e20, 0x2fc7a160, 0x7a0d3a00, 0) + 19 bytes
[3] hg.dll:_HG_SetSwitchYard(0x2fc7a160, 0x7a0a1a50, 0x2fd56e20, 0x00dfc48c) + 822 bytes
[4] hg.dll:void __cdecl gobjSet(struct GObject_tag *,struct GO_PropID_tag *,struct mxArray_tag *)(0x2fc7a160, 0x2fdbb0e0, 0x2fd56e20, 0x00dfc550) + 83 bytes
[5] hg.dll:_HO_Set(0x2fc7a160, 0x2fdbb0e0, 0x2fd56e20, 0x019a93b0 "à°Û/") + 21 bytes
[6] hg.dll:_hobjSetPairs(0x2fc7a160, 0x019a93b0 "à°Û/", 0x019a84b0 " nÕ/", 1) + 173 bytes
[7] hg.dll:void __cdecl gobjSetPairs(struct GObject_tag *,struct GO_PropID_tag * *,struct mxArray_tag * *,int)(0x2fc7a160, 0x019a93b0 "à°Û/", 0x019a84b0 " nÕ/", 1) + 84 bytes
[snip]

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This issue has been verified in MATLAB 6.5 (R13).
When using a cell array as the value for a callback, the cell elements should not contain empty matrices. The first cell element should contain a function handle, or a string containing the name of a function. The first two inputs to the specified function will automatically be the handle for the callback object and event data. Elements 2...N of the cell array will be passed as inputs 3...N+1 to the function.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!