Browse Source

fix: crash when tray is destroyed (#14357)

Release the view of status item before destroying it,
gives chance to perform cleanup on the view.
trop[bot] 6 years ago
parent
commit
873f39b159
1 changed files with 8 additions and 0 deletions
  1. 8 0
      atom/browser/ui/tray_icon_cocoa.mm

+ 8 - 0
atom/browser/ui/tray_icon_cocoa.mm

@@ -41,9 +41,16 @@ const CGFloat kVerticalTitleMargin = 2;
 
 @implementation StatusItemView
 
+- (void)dealloc {
+  trayIcon_ = nil;
+  menuController_ = nil;
+  [super dealloc];
+}
+
 - (id)initWithImage:(NSImage*)image icon:(atom::TrayIconCocoa*)icon {
   image_.reset([image copy]);
   trayIcon_ = icon;
+  menuController_ = nil;
   highlight_mode_ = atom::TrayIcon::HighlightMode::SELECTION;
   ignoreDoubleClickEvents_ = NO;
   forceHighlight_ = NO;
@@ -89,6 +96,7 @@ const CGFloat kVerticalTitleMargin = 2;
     trackingArea_.reset();
   }
   [[NSStatusBar systemStatusBar] removeStatusItem:statusItem_];
+  [statusItem_ setView:nil];
   statusItem_.reset();
 }