Why do I receive a segmentation violation when closing a GUI used with UIWAIT in MATLAB?

Why do I receive a segmentation violation when closing a GUI used with UIWAIT in MATLAB?
I have a GUI that I use to capture and process input; this returns a variable when it closes. I use UIWAIT to suspend additional MATLAB code until the GUI is closed. However, if I try to close the GUI after entering text in one of its text boxes, I receive a segmentation violation:
Segmentation violation detected at Thu Jan 23 10:11:21 2003
------------------------------------------------------------------------
Configuration:
MATLAB Version: 6.1.0.450 (R12.1)
Operating System: Microsoft Windows 2000
Window System: Version 5.0 (Build 2195: Service Pack 2)
Processor ID: x86 Family 6 Model 5 Stepping 2, GenuineIntel
Virtual Machine: Java 1.1.8 from Sun Microsystems Inc.
Register State:
EAX =3D 00000000 EBX =3D 1a956b30
ECX =3D 1afc9d80 EDX =3D 0174b1bc
ESI =3D 00000000 EDI =3D 02d67960
EBP =3D 01495bfc ESP =3D 01495bfc
EIP =3D 01734616 FLG =3D 00010202
Stack Trace:
[0] hg.dll:_ggo_children(0, 0x02d67960, 0x1afc9d80, 0x01495c38) + 6 bytes
[1] hg.dll:_recursive_destroy_GO_children(0, 0x018789a6, 0x1afc9d80, 0) +
17 bytes
[2] hg.dll:public: virtual void __thiscall
HGInterface::destroyTree(void)(0x1a956b30, 1, 0x01495eb0, 0x01a23cac) + 11
bytes
[3] hg.dll:_hgDeleteThroughUDD(1, 0x01495cc0, 0x0173bdc6, 0x02fb9a80
"currFig") + 173 bytes
[4] hg.dll:_hgDelete(0x02fb9a80 "currFig", 0, 2, 0x0149618c) + 12 bytes
[5] hg.dll:_hgFullDeleteFcn(0, 0x01495ce4, 1, 0x01495eac) + 54 bytes
[6] m_interpreter.dll:_inExecuteInternalFcn(66, 1, 0, 0) + 1122 bytes
[7] m_interpreter.dll:_inInterPcode(1, 0x014971e4, 0, 0x1acf0b70) + 2320
bytes
[8] m_interpreter.dll:_inWord(0, 0x01496edc, 0, 0x014971e4) + 622 bytes
[9] m_interpreter.dll:_inWordsj(0, 0x01496edc, 0, 0x014971e4) + 823 bytes
[10] m_interpreter.dll:_inRunMP(0, 0x01496edc, 0, 0x014971e4) + 141 bytes
...

 Accepted Answer

This is a bug in MATLAB 6.5 (R13) and earlier versions. The reason for the problem appears to be a conflict between the text box's Callback and the UIWAIT function. The Callback function for a text box is called after the text box loses focus. That means it is called after typing in a string and then clicking on something else. The problem is caused when the 'something else' that is clicked on is the 'x' to close the window. Because UIWAIT was used, MATLAB stopped the orginal call to the function and is waiting for it to close.
Instead of immediately closing the window, first click on another area of the window, or press Return. This will execute the Callback of the text box. Then closing the window will not cause a segmentation violation.

More Answers (0)

Categories

Products

Community Treasure Hunt

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

Start Hunting!