NSToolbar with NSSearchField crash

  • Hello,

    I have a toolbar that has an NSSearchField in it, using setView: on NSToolbarItem. However, I am experiencing a crash when running the toolbar customisation palette, when the search field is not visible and the user attempts to drag the search field to the toolbar. The debugger just shows lots of private and internal methods, but things seem to crash on NSMenuItem -encodeWithCoder:. My search field has a menu, and it seems that this is what is causing problems for the customisation palette. If I disconnect the menu from the search field, I don't get any crashes, so this is almost certainly the culprit.

    So, my question is, how do I fix this? I notice that in Xcode, the search field only shows its menu drop down arrow when it is actually in the toolbar, and not in the customisation palette, but I don't know how I would go about disconnecting the menu only in this circumstance. Other programs, such as DevonThink and Camino, don't seem to have any problems with having a menu in a search field in the toolbar customisation palette...

    If anyone could give me any advice on how to fix this bug, I would be most grateful.
    Many thanks in advance,
    Keith
  • Can you provide a crash debugger stack trace?

    --
    mikey

    On 17 Oct, 2006, at 16:52, Keith Blount wrote:

    > Hello,
    >
    > I have a toolbar that has an NSSearchField in it, using setView: on
    > NSToolbarItem. However, I am experiencing a crash when running the
    > toolbar customisation palette, when the search field is not visible
    > and the user attempts to drag the search field to the toolbar. The
    > debugger just shows lots of private and internal methods, but
    > things seem to crash on NSMenuItem -encodeWithCoder:. My search
    > field has a menu, and it seems that this is what is causing
    > problems for the customisation palette. If I disconnect the menu
    > from the search field, I don't get any crashes, so this is almost
    > certainly the culprit.
    >
    > So, my question is, how do I fix this? I notice that in Xcode, the
    > search field only shows its menu drop down arrow when it is
    > actually in the toolbar, and not in the customisation palette, but
    > I don't know how I would go about disconnecting the menu only in
    > this circumstance. Other programs, such as DevonThink and Camino,
    > don't seem to have any problems with having a menu in a search
    > field in the toolbar customisation palette...
    >
    > If anyone could give me any advice on how to fix this bug, I would
    > be most grateful.
    > Many thanks in advance,
    > Keith
    >
    >
    >
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/mikey-san%
    > 40bungie.org
    >
    > This email sent to <mikey-san...>
  • Sure - here is the crash stack trace - you can see that it crashes around the point of [NSMenuItem encodeWithCoder:], and, like I say, it does seem to be the including of the menu in the search field that causes the crash when trying to drag the search field from the customisation palette to the toolbar. If there is no menu, everything works fine. Thanks.

    Exception:  EXC_BAD_ACCESS (0x0001)
    Codes:      KERN_PROTECTION_FAILURE (0x0002) at 0x00000010

    Thread 0 Crashed:
    0  libobjc.A.dylib                    0x90a3e2e8 _class_lookupMethodAndLoadCache + 112
    1  libobjc.A.dylib                    0x90a3e1d4 objc_msgSend + 244
    2  com.apple.Foundation              0x929a7cec _encodeObject + 104
    3  com.apple.AppKit                  0x93a50a10 -[NSMenuItem encodeWithCoder:] + 1228
    4  com.apple.Foundation              0x929a8008 _encodeObject + 900
    5  com.apple.Foundation              0x929a8654 -[NSKeyedArchiver _encodeArrayOfObjects:forKey:] + 312
    6  com.apple.Foundation              0x929a24fc -[NSArray encodeWithCoder:] + 252
    7  com.apple.Foundation              0x929a8008 _encodeObject + 900
    8  com.apple.AppKit                  0x93a4ed24 -[NSMenu encodeWithCoder:] + 196
    9  com.apple.Foundation              0x929a8008 _encodeObject + 900
    10  com.apple.AppKit                  0x93b6bcbc -[NSSearchFieldCell encodeWithCoder:] + 960
    11  com.apple.Foundation              0x929a8008 _encodeObject + 900
    12  com.apple.AppKit                  0x9382efcc -[NSControl encodeWithCoder:] + 320
    13  com.apple.AppKit                  0x9382edb4 -[NSTextField encodeWithCoder:] + 64
    14  com.apple.AppKit                  0x93b6b2d4 -[NSSearchField encodeWithCoder:] + 64
    15  com.apple.Foundation              0x929a8008 _encodeObject + 900
    16  com.apple.Foundation              0x929a9010 +[NSKeyedArchiver archivedDataWithRootObject:] + 148
    17  com.apple.AppKit                  0x93b07654 -[NSToolbarItem _copyOfCustomView] + 44
    18  com.apple.AppKit                  0x93b0772c -[NSToolbarItem copyWithZone:] + 148
    19  com.apple.AppKit                  0x93b0f1c4 -[NSToolbarView(_ItemDragAndDropSupport) _beginSrcDragItemWithEvent:] + 568
    20  com.apple.AppKit                  0x93b0c0f8 -[NSToolbarView mouseDown:] + 68
    21  com.apple.AppKit                  0x93729890 -[NSWindow sendEvent:] + 4616
    22  com.apple.AppKit                  0x936d28d4 -[NSApplication sendEvent:] + 4172
    23  ...iteratureandlatte.scrivener    0x000155d4 -[SCRApplication sendEvent:] + 600 (crt.c:355)
    24  com.apple.AppKit                  0x936c9d10 -[NSApplication run] + 508
    25  com.apple.AppKit                  0x937ba87c NSApplicationMain + 452
    26  ...iteratureandlatte.scrivener    0x00002b88 _start + 340 (crt.c:272)
    27  ...iteratureandlatte.scrivener    0x00002a30 start + 60

    Thread 1:
    0  libSystem.B.dylib                  0x9000b268 mach_msg_trap + 8
    1  libSystem.B.dylib                  0x9000b1bc mach_msg + 60
    2  com.apple.CoreGraphics            0x903d86dc _CGSFlushRegionInline + 156
    3  com.apple.CoreGraphics            0x903d805c _CGSFlushWindowRegion + 296
    4  com.apple.CoreGraphics            0x903d7ba0 CGSDeviceSynchronize + 552
    5  libRIP.A.dylib                    0x946ee8dc ripc_Context + 124
    6  com.apple.AppKit                  0x93717f3c -[NSWindow flushWindow] + 288
    7  com.apple.Foundation              0x9294b5e8 -[NSArray makeObjectsPerformSelector:withObject:] + 264
    8  com.apple.AppKit                  0x9376a9c4 -[NSUIHeartBeat _heartBeatThread:] + 1024
    9  com.apple.Foundation              0x92944194 forkThreadForFunction + 108
    10  libSystem.B.dylib                  0x9002bc28 _pthread_body + 96

    ----- Original Message ----
    From: Michael Watson <mikey-san...>
    To: Keith Blount <keithblount...>
    Cc: <cocoa-dev...>
    Sent: Tuesday, October 17, 2006 10:16:19 PM
    Subject: Re: NSToolbar with NSSearchField crash

    Can you provide a crash debugger stack trace?

    --
    mikey

    On 17 Oct, 2006, at 16:52, Keith Blount wrote:

    > Hello,
    >
    > I have a toolbar that has an NSSearchField in it, using setView: on
    > NSToolbarItem. However, I am experiencing a crash when running the
    > toolbar customisation palette, when the search field is not visible
    > and the user attempts to drag the search field to the toolbar. The
    > debugger just shows lots of private and internal methods, but
    > things seem to crash on NSMenuItem -encodeWithCoder:. My search
    > field has a menu, and it seems that this is what is causing
    > problems for the customisation palette. If I disconnect the menu
    > from the search field, I don't get any crashes, so this is almost
    > certainly the culprit.
    >
    > So, my question is, how do I fix this? I notice that in Xcode, the
    > search field only shows its menu drop down arrow when it is
    > actually in the toolbar, and not in the customisation palette, but
    > I don't know how I would go about disconnecting the menu only in
    > this circumstance. Other programs, such as DevonThink and Camino,
    > don't seem to have any problems with having a menu in a search
    > field in the toolbar customisation palette...
    >
    > If anyone could give me any advice on how to fix this bug, I would
    > be most grateful.
    > Many thanks in advance,
    > Keith
    >
    >
    >
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/mikey-san%
    > 40bungie.org
    >
    > This email sent to <mikey-san...>
previous month october 2006 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today