mirror of
				https://github.com/godotengine/godot.git
				synced 2025-11-03 23:21:15 +00:00 
			
		
		
		
	Editor: Fix EditorHelpBitTooltip + ProgressDialog causes crash
				
					
				
			This commit is contained in:
		
							parent
							
								
									107fd30ae7
								
							
						
					
					
						commit
						18fca3c294
					
				
					 2 changed files with 19 additions and 1 deletions
				
			
		| 
						 | 
					@ -3760,6 +3760,14 @@ EditorHelpBit::EditorHelpBit(const String &p_symbol) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// EditorHelpBitTooltip ///
 | 
					/// EditorHelpBitTooltip ///
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void EditorHelpBitTooltip::_safe_queue_free() {
 | 
				
			||||||
 | 
						if (_pushing_input > 0) {
 | 
				
			||||||
 | 
							_need_free = true;
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							queue_free();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void EditorHelpBitTooltip::_notification(int p_what) {
 | 
					void EditorHelpBitTooltip::_notification(int p_what) {
 | 
				
			||||||
	switch (p_what) {
 | 
						switch (p_what) {
 | 
				
			||||||
		case NOTIFICATION_WM_MOUSE_ENTER:
 | 
							case NOTIFICATION_WM_MOUSE_ENTER:
 | 
				
			||||||
| 
						 | 
					@ -3778,7 +3786,13 @@ void EditorHelpBitTooltip::_input_from_window(const Ref<InputEvent> &p_event) {
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		const Ref<InputEventMouse> mouse_event = p_event;
 | 
							const Ref<InputEventMouse> mouse_event = p_event;
 | 
				
			||||||
		if (mouse_event.is_null()) {
 | 
							if (mouse_event.is_null()) {
 | 
				
			||||||
 | 
								// GH-91652. Prevents use-after-free since `ProgressDialog` calls `Main::iteration()`.
 | 
				
			||||||
 | 
								_pushing_input++;
 | 
				
			||||||
			get_parent_viewport()->push_input(p_event);
 | 
								get_parent_viewport()->push_input(p_event);
 | 
				
			||||||
 | 
								_pushing_input--;
 | 
				
			||||||
 | 
								if (_pushing_input <= 0 && _need_free) {
 | 
				
			||||||
 | 
									queue_free();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -3839,7 +3853,7 @@ EditorHelpBitTooltip::EditorHelpBitTooltip(Control *p_target) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	timer = memnew(Timer);
 | 
						timer = memnew(Timer);
 | 
				
			||||||
	timer->set_wait_time(0.2);
 | 
						timer->set_wait_time(0.2);
 | 
				
			||||||
	timer->connect("timeout", callable_mp(static_cast<Node *>(this), &Node::queue_free));
 | 
						timer->connect("timeout", callable_mp(this, &EditorHelpBitTooltip::_safe_queue_free));
 | 
				
			||||||
	add_child(timer);
 | 
						add_child(timer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ERR_FAIL_NULL(p_target);
 | 
						ERR_FAIL_NULL(p_target);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -325,6 +325,10 @@ class EditorHelpBitTooltip : public PopupPanel {
 | 
				
			||||||
	GDCLASS(EditorHelpBitTooltip, PopupPanel);
 | 
						GDCLASS(EditorHelpBitTooltip, PopupPanel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Timer *timer = nullptr;
 | 
						Timer *timer = nullptr;
 | 
				
			||||||
 | 
						int _pushing_input = 0;
 | 
				
			||||||
 | 
						bool _need_free = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void _safe_queue_free();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
	void _notification(int p_what);
 | 
						void _notification(int p_what);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue