Hi,

I have just a tab view on my main window and I switch tabs based on user input.
First tab has three hover buttons and on clicking one of them, it takes to 
another tab which two hover buttons.
After clicking one of the two hover buttons, I switch tab and show a table view 
and then show and end a sheet.
On clicking another button there I bring another sheet with radio buttons and 
on clicking a radio button, it just crashed, many seconds after the last hover 
button was clicked.

The crash report says something about _updateTrackingAreas, so I have detailed 
about the situation above.

Part of code is reproduced below.

@interface HoverButton : NSButton
{
        NSTrackingArea *trackingArea;
        BOOL hovering;
}

//-------- Implementation
- (void)ensureTrackingArea
{
    if (trackingArea == nil) {
        trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
                                                    options: 
(NSTrackingMouseEnteredAndExited | NSTrackingActiveInKeyWindow | 
NSTrackingInVisibleRect)
                                                      owner:self userInfo:nil];
    }
}

- (void)updateTrackingAreas
{
    if (trackingArea) {
        [trackingArea release];
        trackingArea = nil;
    }
    [self ensureTrackingArea];
    [self addTrackingArea:trackingArea];
    [super updateTrackingAreas];
}

- (void)mouseExited:(NSEvent *)theEvent
{
        // shows one image over the button
}

- (void)mouseEntered:(NSEvent *)theEvent
{
        // shows another image over the button
}

Part of the crash report stack trace:

Application Specific Information:
objc_msgSend() selector name: retain
objc[347]: garbage collection is OFF

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib                             0x00007fff97c31350      
objc_msgSend_vtable13 + 16
1   com.apple.CoreFoundation            0x00007fff96525b87      +[__NSArrayI 
__new::] + 167
2   com.apple.CoreFoundation            0x00007fff96525a75      
-[__NSPlaceholderArray initWithObjects:count:] + 245
3   com.apple.CoreFoundation            0x00007fff965287c0      -[NSArray 
initWithArray:range:copyItems:] + 816
4   com.apple.CoreFoundation            0x00007fff96528482      -[NSArray 
initWithArray:copyItems:] + 66
5   com.apple.CoreFoundation            0x00007fff9654caf6      -[__NSArrayM 
copyWithZone:] + 54
6   com.apple.CoreFoundation            0x00007fff96524d54      -[NSObject 
copy] + 20
7   com.apple.AppKit                            0x00007fff942a7ad2      
-[NSView(NSInternal) _updateTrackingAreas] + 1295
8   com.apple.CoreFoundation            0x00007fff96574cee      
__NSArrayEnumerate + 718
9   com.apple.AppKit                            0x00007fff942a7aeb      
-[NSView(NSInternal) _updateTrackingAreas] + 1320
10  com.apple.CoreFoundation            0x00007fff96574cee      
__NSArrayEnumerate + 718
11  com.apple.AppKit                    0x00007fff942a7aeb      
-[NSView(NSInternal) _updateTrackingAreas] + 1320
12  com.apple.CoreFoundation            0x00007fff96574cee      
__NSArrayEnumerate + 718
13  com.apple.AppKit                    0x00007fff942a7aeb      
-[NSView(NSInternal) _updateTrackingAreas] + 1320
14  com.apple.CoreFoundation            0x00007fff96574cee      
__NSArrayEnumerate + 718
15  com.apple.AppKit                    0x00007fff942a7aeb      
-[NSView(NSInternal) _updateTrackingAreas] + 1320
16  com.apple.CoreFoundation            0x00007fff96574cee      
__NSArrayEnumerate + 718
17  com.apple.AppKit                    0x00007fff942a7aeb      
-[NSView(NSInternal) _updateTrackingAreas] + 1320
18  com.apple.CoreFoundation            0x00007fff96574cee      
__NSArrayEnumerate + 718
19  com.apple.AppKit                    0x00007fff942a7aeb      
-[NSView(NSInternal) _updateTrackingAreas] + 1320
20  com.apple.CoreFoundation            0x00007fff96574cee      
__NSArrayEnumerate + 718
21  com.apple.AppKit                    0x00007fff942a7aeb      
-[NSView(NSInternal) _updateTrackingAreas] + 1320
22  com.apple.AppKit                    0x00007fff942a7444      __-[NSWindow 
_postInvalidCursorRects]_block_invoke_1 + 1107
23  com.apple.CoreFoundation            0x00007fff9653c8e7 
__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
24  com.apple.CoreFoundation            0x00007fff9653c846      
__CFRunLoopDoObservers + 374
25  com.apple.CoreFoundation            0x00007fff96511af9      __CFRunLoopRun 
+ 825
26  com.apple.CoreFoundation            0x00007fff96511486      
CFRunLoopRunSpecific + 230
27  com.apple.HIToolbox                 0x00007fff959702bf      
RunCurrentEventLoopInMode + 277
28  com.apple.HIToolbox                 0x00007fff959774bf      
ReceiveNextEventCommon + 181
29  com.apple.HIToolbox                 0x00007fff959773fa      
BlockUntilNextEventMatchingListInMode + 62
30  com.apple.AppKit                    0x00007fff941e1779      _DPSNextEvent + 
659
31  com.apple.AppKit                    0x00007fff941e107d      -[NSApplication 
nextEventMatchingMask:untilDate:inMode:dequeue:] + 135
32  com.apple.AppKit                    0x00007fff941dd9b9      -[NSApplication 
run] + 470
33  com.apple.AppKit                    0x00007fff94459eac      
NSApplicationMain + 867
34  com.MyCompany.MyProduct     0x00000001063c00b4      start + 52

My questions are:

1. After adding tracking area initially, will it be okay to not release and add 
it again since the button is not resizable?
2. In updateTrackingAreas method, does it matter if the [super 
updateTrackingAreas]; is called in the beginning or the end?
3. Do I need to do something when the tab showing the hover button is not 
visible considering the options used to init the trackingArea.
4. What could have caused the crash?

I am using HoverButton in the nib file by setting the class to HoverButton, and 
not programatically. The code is non-ARC and non-GC.

Any help would be greatly appreciated.

Thanks,
Nick

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to