Jelajahi Sumber

Fix crash when GraphNode wasn't a child of a Control

Johan Manuel 9 tahun lalu
induk
melakukan
580b4465c6
1 mengubah file dengan 5 tambahan dan 0 penghapusan
  1. 5 0
      scene/gui/graph_node.cpp

+ 5 - 0
scene/gui/graph_node.cpp

@@ -559,7 +559,12 @@ Color GraphNode::get_connection_output_color(int p_idx) {
 void GraphNode::_input_event(const InputEvent& p_ev) {
 void GraphNode::_input_event(const InputEvent& p_ev) {
 
 
 	if (p_ev.type==InputEvent::MOUSE_BUTTON) {
 	if (p_ev.type==InputEvent::MOUSE_BUTTON) {
+
+		ERR_EXPLAIN("GraphNode must be the child of a GraphEdit node.");
+		ERR_FAIL_COND(get_parent_control() == NULL);
+
 		get_parent_control()->grab_focus();
 		get_parent_control()->grab_focus();
+
 		if(p_ev.mouse_button.pressed && p_ev.mouse_button.button_index==BUTTON_LEFT) {
 		if(p_ev.mouse_button.pressed && p_ev.mouse_button.button_index==BUTTON_LEFT) {
 
 
 			Vector2 mpos = Vector2(p_ev.mouse_button.x,p_ev.mouse_button.y);
 			Vector2 mpos = Vector2(p_ev.mouse_button.x,p_ev.mouse_button.y);