From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Biru Mohanathas <birunthan@mohanathas.com>
Date: Thu, 10 Dec 2020 19:02:37 +0200
Subject: fix crash in NativeViewHost::SetParentAccessible

This fixes random crashes on Windows 10. It presumably started happening
after the changes in
https://chromium.googlesource.com/chromium/src.git/+/5c6c8e994bce2bfb867279ae5068e9f9134e70c3%5E!/#F15

For context, see: https://github.com/electron/electron/issues/26905

This patch can likely be upstreamed. The crash cannot be fixed without
patching something in Chromium - this is the least invasive change.

diff --git a/ui/views/controls/native/native_view_host.cc b/ui/views/controls/native/native_view_host.cc
index d8e5cf4ddb625519863837544c2f91b4e015029b..e1c2e2e41eed722a7989bc8e97e2ea73119b1f70 100644
--- a/ui/views/controls/native/native_view_host.cc
+++ b/ui/views/controls/native/native_view_host.cc
@@ -54,6 +54,9 @@ void NativeViewHost::Detach() {
 }
 
 void NativeViewHost::SetParentAccessible(gfx::NativeViewAccessible accessible) {
+  if (!native_wrapper_.get())
+    return;
+
   native_wrapper_->SetParentAccessible(accessible);
 }
 
