Repository navigation
Removed tracking area for tray to prevent mouse leave race condition crash - #11272
Conversation
|
💖 Thanks for opening this pull request! 💖 Here is a list of things that will help get it across the finish line:
|
| base::scoped_nsobject<NSImage> alternateImage_; | ||
| base::scoped_nsobject<NSString> title_; | ||
| base::scoped_nsobject<NSStatusItem> statusItem_; | ||
| NSTrackingArea *trackingArea_; |
There was a problem hiding this comment.
This should be a managed pointer:
base::scoped_nsobject<NSTrackingArea> trackingArea_;
|
|
||
| - (void)removeItem { | ||
| // Turn off tracking events to prevent crash | ||
| [self removeTrackingArea:trackingArea_]; |
There was a problem hiding this comment.
We need to
- Release the trackingArea_ pointer
- Safeguard against multiple calls
if (trackingArea_) {
[self removeTrackingArea:trackingArea_];
trackingArea_.reset();
}
|
|
||
| // Add NSTrackingArea for listening to mouseEnter and mouseExit events | ||
| auto trackingArea = [[[NSTrackingArea alloc] | ||
| trackingArea_ = [[[NSTrackingArea alloc] |
There was a problem hiding this comment.
This needs to be alloced into the managed pointer:
trackingArea_.reset([[NSTrackingArea alloc] args...);
[self addTrackingArea:trackingArea_];
|
Have made the changes to the mem management |
|
These CI failures seem unrelated to the pull request. I've pinged @jkleinsc in the #ci channel for a second opinion. |
felixrieseberg
left a comment
There was a problem hiding this comment.
Logic seems sound to me. I have never seen the crash, but this is a cheap operation that makes sense to me.
MarshallOfSound
left a comment
There was a problem hiding this comment.
This shouldn't go straight to 1.7.x, it should go to master and then backported manually after the initial merge
|
+1 on putting this in master |
|
@matt-way can you do this change in master instead of 1-7-x? It can then be manually backported to 1-7-x |
|
The failing test is not related to this PR, I'm merging this anyway. |
|
Congrats on merging your first pull request! 🎉🎉🎉 |
When the tray icon is destroyed, sometimes a
mouseExitedevent is triggered late, causing a crash. This is fixed by explicitly removing the tracking area when removing the tray icon.