Merge pull request #11272 from syntropy-ai/1-7-x
Removed tracking area for tray to prevent mouse leave race condition crash
This commit is contained in:
commit
143816bee1
1 changed files with 9 additions and 3 deletions
|
@ -33,6 +33,7 @@ const CGFloat kVerticalTitleMargin = 2;
|
||||||
base::scoped_nsobject<NSString> title_;
|
base::scoped_nsobject<NSString> title_;
|
||||||
base::scoped_nsobject<NSMutableAttributedString> attributedTitle_;
|
base::scoped_nsobject<NSMutableAttributedString> attributedTitle_;
|
||||||
base::scoped_nsobject<NSStatusItem> statusItem_;
|
base::scoped_nsobject<NSStatusItem> statusItem_;
|
||||||
|
base::scoped_nsobject<NSTrackingArea> trackingArea_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end // @interface StatusItemView
|
@end // @interface StatusItemView
|
||||||
|
@ -61,12 +62,12 @@ const CGFloat kVerticalTitleMargin = 2;
|
||||||
[self updateDimensions];
|
[self updateDimensions];
|
||||||
|
|
||||||
// Add NSTrackingArea for listening to mouseEnter, mouseExit, and mouseMove events
|
// Add NSTrackingArea for listening to mouseEnter, mouseExit, and mouseMove events
|
||||||
auto trackingArea = [[[NSTrackingArea alloc]
|
trackingArea_.reset([[NSTrackingArea alloc]
|
||||||
initWithRect:[self bounds]
|
initWithRect:[self bounds]
|
||||||
options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveAlways
|
options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveAlways
|
||||||
owner:self
|
owner:self
|
||||||
userInfo:nil] autorelease];
|
userInfo:nil]);
|
||||||
[self addTrackingArea:trackingArea];
|
[self addTrackingArea:trackingArea_];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -78,6 +79,11 @@ const CGFloat kVerticalTitleMargin = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)removeItem {
|
- (void)removeItem {
|
||||||
|
// Turn off tracking events to prevent crash
|
||||||
|
if (trackingArea_) {
|
||||||
|
[self removeTrackingArea:trackingArea_];
|
||||||
|
trackingArea_.reset();
|
||||||
|
}
|
||||||
[[NSStatusBar systemStatusBar] removeStatusItem:statusItem_];
|
[[NSStatusBar systemStatusBar] removeStatusItem:statusItem_];
|
||||||
statusItem_.reset();
|
statusItem_.reset();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue