fix: potential crash calling tray.popUpContextMenu()
(#39231)
fix: potential crash calling tray.popUpContextMenu
This commit is contained in:
parent
c8f7a0e052
commit
1f19a74417
7 changed files with 31 additions and 20 deletions
|
@ -83,6 +83,11 @@
|
|||
[self removeTrackingArea:trackingArea_];
|
||||
trackingArea_ = nil;
|
||||
}
|
||||
|
||||
// Ensure any open menu is closed.
|
||||
if ([statusItem_ menu])
|
||||
[[statusItem_ menu] cancelTracking];
|
||||
|
||||
[[NSStatusBar systemStatusBar] removeStatusItem:statusItem_];
|
||||
[self removeFromSuperview];
|
||||
statusItem_ = nil;
|
||||
|
@ -228,7 +233,6 @@
|
|||
if (menuController_ && ![menuController_ isMenuOpen]) {
|
||||
// Ensure the UI can update while the menu is fading out.
|
||||
base::ScopedPumpMessagesInPrivateModes pump_private;
|
||||
|
||||
[[statusItem_ button] performClick:self];
|
||||
}
|
||||
}
|
||||
|
@ -354,16 +358,16 @@ bool TrayIconCocoa::GetIgnoreDoubleClickEvents() {
|
|||
return [status_item_view_ getIgnoreDoubleClickEvents];
|
||||
}
|
||||
|
||||
void TrayIconCocoa::PopUpOnUI(ElectronMenuModel* menu_model) {
|
||||
[status_item_view_ popUpContextMenu:menu_model];
|
||||
void TrayIconCocoa::PopUpOnUI(base::WeakPtr<ElectronMenuModel> menu_model) {
|
||||
[status_item_view_ popUpContextMenu:menu_model.get()];
|
||||
}
|
||||
|
||||
void TrayIconCocoa::PopUpContextMenu(const gfx::Point& pos,
|
||||
raw_ptr<ElectronMenuModel> menu_model) {
|
||||
void TrayIconCocoa::PopUpContextMenu(
|
||||
const gfx::Point& pos,
|
||||
base::WeakPtr<ElectronMenuModel> menu_model) {
|
||||
content::GetUIThreadTaskRunner({})->PostTask(
|
||||
FROM_HERE,
|
||||
base::BindOnce(&TrayIconCocoa::PopUpOnUI, weak_factory_.GetWeakPtr(),
|
||||
base::Unretained(menu_model)));
|
||||
FROM_HERE, base::BindOnce(&TrayIconCocoa::PopUpOnUI,
|
||||
weak_factory_.GetWeakPtr(), menu_model));
|
||||
}
|
||||
|
||||
void TrayIconCocoa::CloseContextMenu() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue