File DesktopNativeWidgetAura-HandleActivationChanged-crash.patch of Package nodejs-electron
From f9819bb70b413c8310cd209c75cc555495e28564 Mon Sep 17 00:00:00 2001
From: Allen Bauer <kylixrd@chromium.org>
Date: Fri, 31 May 2024 15:55:13 +0000
Subject: [PATCH] Harden DesktopNativeWidgetAura against a destroyed Widget.
Under CLIENT_OWNS_WIDGET ownership mode, it is possible for the Widget to have already been destroyed. This hardens the NativeWidget to handle this case without crashing.
Bug: 40242079, 40232479
Change-Id: I455e1690b49ff50e4eac3b9a085d9f15ccb6adec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5585758
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Thomas Anderson <thomasanderson@chromium.org>
Commit-Queue: Allen Bauer <kylixrd@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1308668}
---
ui/views/widget/desktop_aura/desktop_native_widget_aura.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
index 9ae19505357c6b..1974865e8c8a8f 100644
--- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
+++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
@@ -431,8 +431,8 @@ DesktopNativeWidgetAura::tooltip_controller() {
}
void DesktopNativeWidgetAura::HandleActivationChanged(bool active) {
- DCHECK(native_widget_delegate_);
- if (!native_widget_delegate_->ShouldHandleNativeWidgetActivationChanged(
+ if (!native_widget_delegate_ ||
+ !native_widget_delegate_->ShouldHandleNativeWidgetActivationChanged(
active)) {
return;
}