Replaces tracking removal with proper mem management
This commit is contained in:
parent
8df4402722
commit
5504294a6a
1 changed files with 7 additions and 4 deletions
|
@ -33,7 +33,7 @@ const CGFloat kVerticalTitleMargin = 2;
|
|||
base::scoped_nsobject<NSString> title_;
|
||||
base::scoped_nsobject<NSMutableAttributedString> attributedTitle_;
|
||||
base::scoped_nsobject<NSStatusItem> statusItem_;
|
||||
NSTrackingArea *trackingArea_;
|
||||
base::scoped_nsobject<NSTrackingArea> trackingArea_;
|
||||
}
|
||||
|
||||
@end // @interface StatusItemView
|
||||
|
@ -62,11 +62,11 @@ const CGFloat kVerticalTitleMargin = 2;
|
|||
[self updateDimensions];
|
||||
|
||||
// Add NSTrackingArea for listening to mouseEnter, mouseExit, and mouseMove events
|
||||
trackingArea_ = [[[NSTrackingArea alloc]
|
||||
trackingArea_.reset([[NSTrackingArea alloc]
|
||||
initWithRect:[self bounds]
|
||||
options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveAlways
|
||||
owner:self
|
||||
userInfo:nil] autorelease];
|
||||
userInfo:nil]);
|
||||
[self addTrackingArea:trackingArea_];
|
||||
}
|
||||
return self;
|
||||
|
@ -80,7 +80,10 @@ const CGFloat kVerticalTitleMargin = 2;
|
|||
|
||||
- (void)removeItem {
|
||||
// Turn off tracking events to prevent crash
|
||||
[self removeTrackingArea:trackingArea_];
|
||||
if (trackingArea_) {
|
||||
[self removeTrackingArea:trackingArea_];
|
||||
trackingArea_.reset();
|
||||
}
|
||||
[[NSStatusBar systemStatusBar] removeStatusItem:statusItem_];
|
||||
statusItem_.reset();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue