Fw.up Clicking on a disabled ComboBox: runtime bug?!?
Fw.up Clicking on a disabled ComboBox: runtime bug?!?
- Subject: Fw.up Clicking on a disabled ComboBox: runtime bug?!?
- From: Andrea Perego <email@hidden>
- Date: Thu, 31 Jan 2002 14:42:15 +0100
Hi!
I posted a message yesterday about a crash when one clicks in a
window where more disabled combo boxes are located.
My application uses a panel/palette window with some controls that
operate on a kind of document. Those controls are located within a
tabview and are disabled by code when no main window exists (or if
the main window does not display data of the appropriate kind). So
far, so good. One of the panes of my tabview contains some
"NSComboBox" instances, which work Ok, but for the fact that, if
*all* the controls of the pane are disabled (-setEnabled:NO) and one
clicks on any of the combo boxes, the application crashes in a
"funny" way.
A "bad access" message appears and, if one is using gdb, the stack
frame area remains empty for, say, ten seconds or more; then, it
fills up with a very large list, more than 500 items, where no one
seems to refer to an application-specific method. I'm not so precise
here, since I'm just asking whether my story is a well-known one.
Besides the combo boxes, the pane contains also some buttons, text
fields and popup menus. Clicking on any of them causes no crash.
Also, if one does not disable one of the combo boxes, the crash is
avoided.
I've found a solution/workaround by issuing "-setSelectable:NO" to
each combo box; I'd guess that the behavior is related to the unique
field editor provided by each window, but any suggestion is welcome.
Erik M. Buck (thanks, Erik!) recognized the crash mechanism immediately:
You are describing infinite recursion. Look for a repeating pattern in the
gdb stack trace. Put a break point at a strategic point in the repeating
pattern of calls. Re-run and find out how the recursion started. Then
don't do that.
I've investigated further and it seems that Erik's suggestion "Then
don't do that" might, perhaps, be forwarded to Apple:
I used gdb to "debug" Interface Builder (I don't feel at ease saying
that I "debugged" Apple code, but this is the purpose gdb is used
for!).
After starting the application, I took the following steps:
- I choose "New / Cocoa App"
- I dragged two combo boxes from the palette into the default window
which is provided by the previous step
- I set their attributes: enabled=OFF / editable=ON
- I chose "Test user interface"
- I clicked onto one of the combos
Then, Interface Builder crashed with:
Program received signal EXC_BAD_ACCESS, Could not access memory.
0x70bb5a40 in _runningOnAppKitThread ()
a stack trace (thanks to "Terminal" ability to remember a lot of
lines!) revealed:
#0 0x70bb5a40 in _runningOnAppKitThread ()
#1 0x70bf5e08 in -[NSWindow _postingDisabled] ()
#2 0x70bed998 in -[NSWindow setViewsNeedDisplay:] ()
#3 0x70bf0130 in -[NSView setNeedsDisplayInRect:] ()
#4 0x70c73930 in -[NSView setKeyboardFocusRingNeedsDisplayInRect:] ()
#5 0x70c73678 in -[NSControl updateCell:] ()
#6 0x70c76420 in -[NSControl resignFirstResponder] ()
#7 0x70c7d198 in -[NSWindow makeFirstResponder:] ()
#8 0x70c51610 in -[NSWindow selectKeyViewFollowingView:] ()
#9 0x70c2c290 in -[NSTextField selectText:] ()
....again and again......
#6185 0x70c2c290 in -[NSTextField selectText:] ()
#6186 0x70c2928c in -[NSTextField becomeFirstResponder] ()
#6187 0x70c7d1ec in -[NSWindow makeFirstResponder:] ()
#6188 0x70c51610 in -[NSWindow selectKeyViewFollowingView:] ()
#6189 0x70c2c290 in -[NSTextField selectText:] ()
#6190 0x70c2928c in -[NSTextField becomeFirstResponder] ()
#6191 0x70c7d1ec in -[NSWindow makeFirstResponder:] ()
#6192 0x70c51610 in -[NSWindow selectKeyViewFollowingView:] ()
#6193 0x70c2c290 in -[NSTextField selectText:] ()
#6194 0x70c2928c in -[NSTextField becomeFirstResponder] ()
#6195 0x70c7d1ec in -[NSWindow makeFirstResponder:] ()
#6196 0x70c1b814 in -[NSWindow sendEvent:] ()
#6197 0x70b9479c in -[NSApplication sendEvent:] ()
#6198 0x00021af0 in ?? ()
#6199 0x70c23488 in -[NSApplication run] ()
#6200 0x00005034 in ?? ()
#6201 0x0000479c in ?? ()
#6202 0x000045cc in ?? ()
The basic recursion loop is:
#6192 0x70c51610 in -[NSWindow selectKeyViewFollowingView:] ()
#6193 0x70c2c290 in -[NSTextField selectText:] ()
#6194 0x70c2928c in -[NSTextField becomeFirstResponder] ()
#6195 0x70c7d1ec in -[NSWindow makeFirstResponder:] ()
It seems that a "bouncing" effect takes place between/among the controls.
By trying other combinations of controls, I discovered that, in order
to cause the crash
- more than a combo box must be located in the view
- each one must be disabled *but* editable.
I'm going to send a bug report on the subject.
Bye
Andrea