fix: detach native view when its removed from parent on macOS (#43627)
Right now DelayedNativeViewHost attaches its underlying native view when it's being attached to a widget but it doesn't detach it when it's being detached. It may lead to use-after-free and crash.
This commit is contained in:
		
					parent
					
						
							
								7222a9fe1f
							
						
					
				
			
			
				commit
				
					
						e64a66bfd3
					
				
			
		
					 1 changed files with 2 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -15,6 +15,8 @@ DelayedNativeViewHost::~DelayedNativeViewHost() = default;
 | 
			
		|||
 | 
			
		||||
void DelayedNativeViewHost::ViewHierarchyChanged(
 | 
			
		||||
    const views::ViewHierarchyChangedDetails& details) {
 | 
			
		||||
  if (!details.is_add && native_view())
 | 
			
		||||
    Detach();
 | 
			
		||||
  NativeViewHost::ViewHierarchyChanged(details);
 | 
			
		||||
  if (details.is_add && GetWidget() && !native_view())
 | 
			
		||||
    Attach(native_view_);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue