Backport Failed
This PR was checked and could not be automatically backported to "24-x-y" cleanly
Details
Failed Diff:
diff --cc shell/browser/ui/tray_icon.cc
index 4415f6c9b7,7f22f3b6da..0000000000
--- a/shell/browser/ui/tray_icon.cc
+++ b/shell/browser/ui/tray_icon.cc
@@@ -21,7 -21,7 +21,11 @@@ void TrayIcon::RemoveBalloon() {
void TrayIcon::Focus() {}
void TrayIcon::PopUpContextMenu(const gfx::Point& pos,
++<<<<<<< HEAD
+ ElectronMenuModel* menu_model) {}
++=======
+ base::WeakPtr<ElectronMenuModel> menu_model) {}
++>>>>>>> fix: potential crash calling tray.popUpContextMenu
void TrayIcon::CloseContextMenu() {}
diff --cc shell/browser/ui/tray_icon.h
index 6654c69ac3,85a66163b6..0000000000
--- a/shell/browser/ui/tray_icon.h
+++ b/shell/browser/ui/tray_icon.h
@@@ -89,7 -89,7 +89,11 @@@ class TrayIcon
// Popups the menu.
virtual void PopUpContextMenu(const gfx::Point& pos,
++<<<<<<< HEAD
+ ElectronMenuModel* menu_model);
++=======
+ base::WeakPtr<ElectronMenuModel> menu_model);
++>>>>>>> fix: potential crash calling tray.popUpContextMenu
virtual void CloseContextMenu();
diff --cc shell/browser/ui/tray_icon_cocoa.h
index 4db1114cd9,d7a7904571..0000000000
--- a/shell/browser/ui/tray_icon_cocoa.h
+++ b/shell/browser/ui/tray_icon_cocoa.h
@@@ -29,11 -32,11 +29,17 @@@ class TrayIconCocoa : public TrayIcon
std::string GetTitle() override;
void SetIgnoreDoubleClickEvents(bool ignore) override;
bool GetIgnoreDoubleClickEvents() override;
- void PopUpOnUI(ElectronMenuModel* menu_model);
+ void PopUpOnUI(base::WeakPtr<ElectronMenuModel> menu_model);
void PopUpContextMenu(const gfx::Point& pos,
++<<<<<<< HEAD
+ ElectronMenuModel* menu_model) override;
+ void CloseContextMenu() override;
+ void SetContextMenu(ElectronMenuModel* menu_model) override;
++=======
+ base::WeakPtr<ElectronMenuModel> menu_model) override;
+ void CloseContextMenu() override;
+ void SetContextMenu(raw_ptr<ElectronMenuModel> menu_model) override;
++>>>>>>> fix: potential crash calling tray.popUpContextMenu
gfx::Rect GetBounds() override;
private:
diff --cc shell/browser/ui/tray_icon_cocoa.mm
index 443bfefb13,9d6d6d4bd0..0000000000
--- a/shell/browser/ui/tray_icon_cocoa.mm
+++ b/shell/browser/ui/tray_icon_cocoa.mm
@@@ -78,11 -81,16 +78,16 @@@
// Turn off tracking events to prevent crash.
if (trackingArea_) {
[self removeTrackingArea:trackingArea_];
- trackingArea_ = nil;
+ trackingArea_.reset();
}
+
+ // Ensure any open menu is closed.
+ if ([statusItem_ menu])
+ [[statusItem_ menu] cancelTracking];
+
[[NSStatusBar systemStatusBar] removeStatusItem:statusItem_];
[self removeFromSuperview];
- statusItem_ = nil;
+ statusItem_.reset();
}
- (void)setImage:(NSImage*)image {
@@@ -358,16 -358,16 +362,21 @@@ bool TrayIconCocoa::GetIgnoreDoubleClic
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()];
}
++<<<<<<< HEAD
+void TrayIconCocoa::PopUpContextMenu(const gfx::Point& pos,
+ ElectronMenuModel* menu_model) {
++=======
+ void TrayIconCocoa::PopUpContextMenu(
+ const gfx::Point& pos,
+ base::WeakPtr<ElectronMenuModel> menu_model) {
++>>>>>>> fix: potential crash calling tray.popUpContextMenu
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() {
diff --cc shell/browser/ui/win/notify_icon.cc
index 2bbbbf2155,2cf6df6054..0000000000
--- a/shell/browser/ui/win/notify_icon.cc
+++ b/shell/browser/ui/win/notify_icon.cc
@@@ -191,7 -191,7 +191,11 @@@ void NotifyIcon::Focus()
}
void NotifyIcon::PopUpContextMenu(const gfx::Point& pos,
++<<<<<<< HEAD
+ ElectronMenuModel* menu_model) {
++=======
+ base::WeakPtr<ElectronMenuModel> menu_model) {
++>>>>>>> fix: potential crash calling tray.popUpContextMenu
// Returns if context menu isn't set.
if (menu_model == nullptr && menu_model_ == nullptr)
return;
diff --cc shell/browser/ui/win/notify_icon.h
index 1568615601,ee45864292..0000000000
--- a/shell/browser/ui/win/notify_icon.h
+++ b/shell/browser/ui/win/notify_icon.h
@@@ -65,9 -66,9 +66,13 @@@ class NotifyIcon : public TrayIcon
void RemoveBalloon() override;
void Focus() override;
void PopUpContextMenu(const gfx::Point& pos,
++<<<<<<< HEAD
+ ElectronMenuModel* menu_model) override;
++=======
+ base::WeakPtr<ElectronMenuModel> menu_model) override;
++>>>>>>> fix: potential crash calling tray.popUpContextMenu
void CloseContextMenu() override;
- void SetContextMenu(raw_ptr<ElectronMenuModel> menu_model) override;
+ void SetContextMenu(ElectronMenuModel* menu_model) override;
gfx::Rect GetBounds() override;
base::WeakPtr<NotifyIcon> GetWeakPtr() { return weak_factory_.GetWeakPtr(); }
Annotations
Check failure on line 24 in shell/browser/ui/tray_icon.cc
trop / Backportable? - 24-x-y
shell/browser/ui/tray_icon.cc#L24
Patch Conflict
Raw output
++<<<<<<< HEAD
+ ElectronMenuModel* menu_model) {}
++=======
+ base::WeakPtr<ElectronMenuModel> menu_model) {}
++>>>>>>> fix: potential crash calling tray.popUpContextMenu
Check failure on line 92 in shell/browser/ui/tray_icon.h
trop / Backportable? - 24-x-y
shell/browser/ui/tray_icon.h#L92
Patch Conflict
Raw output
++<<<<<<< HEAD
+ ElectronMenuModel* menu_model);
++=======
+ base::WeakPtr<ElectronMenuModel> menu_model);
++>>>>>>> fix: potential crash calling tray.popUpContextMenu
Check failure on line 37 in shell/browser/ui/tray_icon_cocoa.h
trop / Backportable? - 24-x-y
shell/browser/ui/tray_icon_cocoa.h#L35-L37
Patch Conflict
Raw output
++<<<<<<< HEAD
+ ElectronMenuModel* menu_model) override;
+ void CloseContextMenu() override;
+ void SetContextMenu(ElectronMenuModel* menu_model) override;
++=======
+ base::WeakPtr<ElectronMenuModel> menu_model) override;
+ void CloseContextMenu() override;
+ void SetContextMenu(raw_ptr<ElectronMenuModel> menu_model) override;
++>>>>>>> fix: potential crash calling tray.popUpContextMenu
Check failure on line 78 in shell/browser/ui/tray_icon_cocoa.mm
trop / Backportable? - 24-x-y
shell/browser/ui/tray_icon_cocoa.mm#L78
Patch Conflict
Check failure on line 372 in shell/browser/ui/tray_icon_cocoa.mm
trop / Backportable? - 24-x-y
shell/browser/ui/tray_icon_cocoa.mm#L371-L372
Patch Conflict
Raw output
++<<<<<<< HEAD
+void TrayIconCocoa::PopUpContextMenu(const gfx::Point& pos,
+ ElectronMenuModel* menu_model) {
++=======
+ void TrayIconCocoa::PopUpContextMenu(
+ const gfx::Point& pos,
+ base::WeakPtr<ElectronMenuModel> menu_model) {
++>>>>>>> fix: potential crash calling tray.popUpContextMenu
Check failure on line 194 in shell/browser/ui/win/notify_icon.cc
trop / Backportable? - 24-x-y
shell/browser/ui/win/notify_icon.cc#L194
Patch Conflict
Raw output
++<<<<<<< HEAD
+ ElectronMenuModel* menu_model) {
++=======
+ base::WeakPtr<ElectronMenuModel> menu_model) {
++>>>>>>> fix: potential crash calling tray.popUpContextMenu
Check failure on line 69 in shell/browser/ui/win/notify_icon.h
trop / Backportable? - 24-x-y
shell/browser/ui/win/notify_icon.h#L69
Patch Conflict
Raw output
++<<<<<<< HEAD
+ ElectronMenuModel* menu_model) override;
++=======
+ base::WeakPtr<ElectronMenuModel> menu_model) override;
++>>>>>>> fix: potential crash calling tray.popUpContextMenu