fix: prevent crash when keyboard event immediately precedes calling BrowserWindow.close() (#27315)
* fix: prevent crash when destroyed widget receives keyboard event Activating a key to close a window will cause a silent crash. Handling the keyboard event will lead to a nullptr dereferenced in Chromium code if the window widget has already been destroyed. * test: ensure BrowserWindow doesn't crash from keyboard events during close
This commit is contained in:
parent
d7b02e123a
commit
4334110339
3 changed files with 17 additions and 0 deletions
|
@ -1417,6 +1417,10 @@ void NativeWindowViews::OnWidgetDestroying(views::Widget* widget) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void NativeWindowViews::OnWidgetDestroyed(views::Widget* changed_widget) {
|
||||
widget_destroyed_ = true;
|
||||
}
|
||||
|
||||
void NativeWindowViews::DeleteDelegate() {
|
||||
if (is_modal() && this->parent()) {
|
||||
auto* parent = this->parent();
|
||||
|
@ -1513,6 +1517,9 @@ void NativeWindowViews::OnWidgetMove() {
|
|||
void NativeWindowViews::HandleKeyboardEvent(
|
||||
content::WebContents*,
|
||||
const content::NativeWebKeyboardEvent& event) {
|
||||
if (widget_destroyed_)
|
||||
return;
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
if (event.windows_key_code == ui::VKEY_BROWSER_BACK)
|
||||
NotifyWindowExecuteAppCommand(kBrowserBackward);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue