diff --git a/ChangeLog b/ChangeLog index 7ea59ce04..5ae1be44d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2012-03-26 Eric Wasylishen + + * Source/GSToolTips.m (-mouseEntered:): When calling the owner's + view:stringForToolTip:point:userData: method, make the point + relative to the view's coordinate system (tested on OS X) instead + of relative to the tracking rect (as before.) + * Source/GSToolTips.m (-_timedOut:): Fix a crash caused by + invalidating the timer and then using its userInfo object. + 2012-03-22 Eric Wasylishen * Source/NSAttributedString.m diff --git a/Source/GSToolTips.m b/Source/GSToolTips.m index 2188332d0..66f3e885b 100644 --- a/Source/GSToolTips.m +++ b/Source/GSToolTips.m @@ -290,13 +290,9 @@ static BOOL restoreMouseMoved; if ([[provider object] respondsToSelector: @selector(view:stringForToolTip:point:userData:)] == YES) { - // According to the Apple docs, the point is relative to the tracking - // rectangle - NSPoint p = [theEvent locationInWindow]; - NSPoint origin = - [view convertRect: [provider viewRect] toView: nil].origin; - p.x -= origin.x; - p.y -= origin.y; + // From testing on OS X, point is in the view's coordinate system + NSPoint p = [view convertPoint: [theEvent locationInWindow] + fromView: nil]; toolTipString = [[provider object] view: view stringForToolTip: [theEvent trackingNumber] point: p @@ -562,7 +558,7 @@ static BOOL restoreMouseMoved; /* The delay timed out -- display the tooltip */ - (void) _timedOut: (NSTimer *)aTimer { - NSString *toolTipString = [aTimer userInfo]; + NSString *toolTipString; NSAttributedString *toolTipText = nil; NSSize textSize; NSPoint mouseLocation = [NSEvent mouseLocation]; @@ -570,6 +566,11 @@ static BOOL restoreMouseMoved; NSRect rect; NSMutableDictionary *attributes; + // retain and autorelease the timer's userinfo because we + // may invalidate the timer (which releases the userinfo), + // but need the userinfo object to remain valid for the + // remainder of this method. + toolTipString = [[[aTimer userInfo] retain] autorelease]; if (nil == toolTipString) { toolTipString = @"";