瀏覽代碼

Add two missing Null checks

These Null checks were removed in #10581 but actually changed the
logic of the functions in this case.

This fixes #10654
Hein-Pieter van Braam 8 年之前
父節點
當前提交
3e25cf9e05
共有 2 個文件被更改,包括 10 次插入3 次删除
  1. 6 2
      modules/gdscript/gd_editor.cpp
  2. 4 1
      scene/main/scene_tree.cpp

+ 6 - 2
modules/gdscript/gd_editor.cpp

@@ -1546,7 +1546,9 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
 							scr = NULL;
 					}
 				} else {
-					on_script = obj->get_script();
+					if (obj) {
+						on_script = obj->get_script();
+					}
 				}
 			}
 
@@ -2237,7 +2239,9 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
 									scr = NULL;
 							}
 						} else {
-							on_script = obj->get_script();
+							if (obj) {
+								on_script = obj->get_script();
+							}
 						}
 					}
 

+ 4 - 1
scene/main/scene_tree.cpp

@@ -1401,8 +1401,11 @@ void SceneTree::_live_edit_create_node_func(const NodePath &p_parent, const Stri
 		Node *n2 = n->get_node(p_parent);
 
 		Node *no = Object::cast_to<Node>(ClassDB::instance(p_type));
-		no->set_name(p_name);
+		if (!no) {
+			continue;
+		}
 
+		no->set_name(p_name);
 		n2->add_child(no);
 	}
 }