fix: crash when tray is destroyed (#14347)
Release the view of status item before destroying it, gives chance to perform cleanup on the view.
This commit is contained in:
parent
85ea0518c5
commit
07d017dc01
1 changed files with 8 additions and 0 deletions
|
@ -41,9 +41,16 @@ const CGFloat kVerticalTitleMargin = 2;
|
||||||
|
|
||||||
@implementation StatusItemView
|
@implementation StatusItemView
|
||||||
|
|
||||||
|
- (void)dealloc {
|
||||||
|
trayIcon_ = nil;
|
||||||
|
menuController_ = nil;
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
- (id)initWithImage:(NSImage*)image icon:(atom::TrayIconCocoa*)icon {
|
- (id)initWithImage:(NSImage*)image icon:(atom::TrayIconCocoa*)icon {
|
||||||
image_.reset([image copy]);
|
image_.reset([image copy]);
|
||||||
trayIcon_ = icon;
|
trayIcon_ = icon;
|
||||||
|
menuController_ = nil;
|
||||||
highlight_mode_ = atom::TrayIcon::HighlightMode::SELECTION;
|
highlight_mode_ = atom::TrayIcon::HighlightMode::SELECTION;
|
||||||
ignoreDoubleClickEvents_ = NO;
|
ignoreDoubleClickEvents_ = NO;
|
||||||
forceHighlight_ = NO;
|
forceHighlight_ = NO;
|
||||||
|
@ -89,6 +96,7 @@ const CGFloat kVerticalTitleMargin = 2;
|
||||||
trackingArea_.reset();
|
trackingArea_.reset();
|
||||||
}
|
}
|
||||||
[[NSStatusBar systemStatusBar] removeStatusItem:statusItem_];
|
[[NSStatusBar systemStatusBar] removeStatusItem:statusItem_];
|
||||||
|
[statusItem_ setView:nil];
|
||||||
statusItem_.reset();
|
statusItem_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue