mirror of
				https://github.com/godotengine/godot.git
				synced 2025-10-31 21:51:22 +00:00 
			
		
		
		
	Avoid potential crash on signal disconnection
This commit is contained in:
		
							parent
							
								
									7a4a6fbc03
								
							
						
					
					
						commit
						32b7f835d8
					
				
					 1 changed files with 5 additions and 1 deletions
				
			
		|  | @ -2097,7 +2097,11 @@ Object::~Object() { | ||||||
| 	// Disconnect signals that connect to this object.
 | 	// Disconnect signals that connect to this object.
 | ||||||
| 	while (connections.size()) { | 	while (connections.size()) { | ||||||
| 		Connection c = connections.front()->get(); | 		Connection c = connections.front()->get(); | ||||||
| 		bool disconnected = c.signal.get_object()->_disconnect(c.signal.get_name(), c.callable, true); | 		Object *obj = c.callable.get_object(); | ||||||
|  | 		bool disconnected = false; | ||||||
|  | 		if (likely(obj)) { | ||||||
|  | 			disconnected = c.signal.get_object()->_disconnect(c.signal.get_name(), c.callable, true); | ||||||
|  | 		} | ||||||
| 		if (unlikely(!disconnected)) { | 		if (unlikely(!disconnected)) { | ||||||
| 			// If the disconnect has failed, abandon the connection to avoid getting trapped in an infinite loop here.
 | 			// If the disconnect has failed, abandon the connection to avoid getting trapped in an infinite loop here.
 | ||||||
| 			connections.pop_front(); | 			connections.pop_front(); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Pedro J. Estébanez
						Pedro J. Estébanez