• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Hover button and tracking area questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Hover button and tracking area questions


  • Subject: Hover button and tracking area questions
  • From: Nick Rogers <email@hidden>
  • Date: Thu, 24 Jan 2013 12:44:35 +0530

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 (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Hover button and tracking area questions
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: Multithreading crash in -[NSConditionLock unlockWithCondition:]
  • Next by Date: Re: Hover button and tracking area questions
  • Previous by thread: Re: Multithreading crash in -[NSConditionLock unlockWithCondition:]
  • Next by thread: Re: Hover button and tracking area questions
  • Index(es):
    • Date
    • Thread