Browse Source

Merge pull request #23789 from vnen/gdscript-empty-class-bug

Check for valid values when checking for class members
Rémi Verschelde 6 years ago
parent
commit
fafece44a2
1 changed files with 20 additions and 0 deletions
  1. 20 0
      modules/gdscript/gdscript_parser.cpp

+ 20 - 0
modules/gdscript/gdscript_parser.cpp

@@ -6432,6 +6432,10 @@ bool GDScriptParser::_get_function_signature(DataType &p_base_type, const String
 	StringName native;
 	StringName native;
 	if (p_base_type.kind == DataType::GDSCRIPT) {
 	if (p_base_type.kind == DataType::GDSCRIPT) {
 		base_gdscript = p_base_type.script_type;
 		base_gdscript = p_base_type.script_type;
+		if (base_gdscript.is_null() || !base_gdscript->is_valid()) {
+			// GDScript wasn't properly compíled, don't bother trying
+			return false;
+		}
 	} else if (p_base_type.kind == DataType::SCRIPT) {
 	} else if (p_base_type.kind == DataType::SCRIPT) {
 		base_script = p_base_type.script_type;
 		base_script = p_base_type.script_type;
 	} else if (p_base_type.kind == DataType::NATIVE) {
 	} else if (p_base_type.kind == DataType::NATIVE) {
@@ -6472,6 +6476,12 @@ bool GDScriptParser::_get_function_signature(DataType &p_base_type, const String
 		base_script = base_script->get_base_script();
 		base_script = base_script->get_base_script();
 	}
 	}
 
 
+	if (native == StringName()) {
+		// Empty native class, might happen in some Script implementations
+		// Just ignore it
+		return false;
+	}
+
 #ifdef DEBUG_METHODS_ENABLED
 #ifdef DEBUG_METHODS_ENABLED
 
 
 	// Only native remains
 	// Only native remains
@@ -6914,6 +6924,10 @@ bool GDScriptParser::_get_member_type(const DataType &p_base_type, const StringN
 	Ref<GDScript> gds;
 	Ref<GDScript> gds;
 	if (base_type.kind == DataType::GDSCRIPT) {
 	if (base_type.kind == DataType::GDSCRIPT) {
 		gds = base_type.script_type;
 		gds = base_type.script_type;
+		if (gds.is_null() || !gds->is_valid()) {
+			// GDScript wasn't properly compíled, don't bother trying
+			return false;
+		}
 	}
 	}
 
 
 	Ref<Script> scr;
 	Ref<Script> scr;
@@ -6976,6 +6990,12 @@ bool GDScriptParser::_get_member_type(const DataType &p_base_type, const StringN
 		scr = scr->get_base_script();
 		scr = scr->get_base_script();
 	}
 	}
 
 
+	if (native == StringName()) {
+		// Empty native class, might happen in some Script implementations
+		// Just ignore it
+		return false;
+	}
+
 	// Check ClassDB
 	// Check ClassDB
 	if (!ClassDB::class_exists(native)) {
 	if (!ClassDB::class_exists(native)) {
 		native = "_" + native.operator String();
 		native = "_" + native.operator String();