Przeglądaj źródła

Merge pull request #18399 from neikeq/u

Mono fixes
Ignacio Etcheverry 7 lat temu
rodzic
commit
6faa96fb89

+ 23 - 16
modules/mono/csharp_script.cpp

@@ -1954,8 +1954,12 @@ Variant CSharpScript::_new(const Variant **p_args, int p_argcount, Variant::Call
 
 
 ScriptInstance *CSharpScript::instance_create(Object *p_this) {
 ScriptInstance *CSharpScript::instance_create(Object *p_this) {
 
 
-	if (!valid)
-		return NULL;
+	if (!script_class) {
+		ERR_EXPLAIN("Cannot find class " + name + " for script " + get_path());
+		ERR_FAIL_V(NULL);
+	}
+
+	ERR_FAIL_COND_V(!valid, NULL);
 
 
 	if (!tool && !ScriptServer::is_scripting_enabled()) {
 	if (!tool && !ScriptServer::is_scripting_enabled()) {
 #ifdef TOOLS_ENABLED
 #ifdef TOOLS_ENABLED
@@ -2045,20 +2049,15 @@ Error CSharpScript::reload(bool p_keep_state) {
 	if (project_assembly) {
 	if (project_assembly) {
 		script_class = project_assembly->get_object_derived_class(name);
 		script_class = project_assembly->get_object_derived_class(name);
 
 
-		if (!script_class) {
-			ERR_PRINTS("Cannot find class " + name + " for script " + get_path());
-		}
+		valid = script_class != NULL;
+
+		if (script_class) {
 #ifdef DEBUG_ENABLED
 #ifdef DEBUG_ENABLED
-		else if (OS::get_singleton()->is_stdout_verbose()) {
 			OS::get_singleton()->print(String("Found class " + script_class->get_namespace() + "." +
 			OS::get_singleton()->print(String("Found class " + script_class->get_namespace() + "." +
 											  script_class->get_name() + " for script " + get_path() + "\n")
 											  script_class->get_name() + " for script " + get_path() + "\n")
 											   .utf8());
 											   .utf8());
-		}
 #endif
 #endif
 
 
-		valid = script_class != NULL;
-
-		if (script_class) {
 			tool = script_class->has_attribute(CACHED_CLASS(ToolAttribute));
 			tool = script_class->has_attribute(CACHED_CLASS(ToolAttribute));
 
 
 			native = GDMonoUtils::get_class_native_base(script_class);
 			native = GDMonoUtils::get_class_native_base(script_class);
@@ -2288,7 +2287,9 @@ RES ResourceFormatLoaderCSharpScript::load(const String &p_path, const String &p
 	CRASH_COND(mono_domain_get() == NULL);
 	CRASH_COND(mono_domain_get() == NULL);
 #endif
 #endif
 
 
-#else
+#endif
+
+#ifdef TOOLS_ENABLED
 	if (Engine::get_singleton()->is_editor_hint() && mono_domain_get() == NULL) {
 	if (Engine::get_singleton()->is_editor_hint() && mono_domain_get() == NULL) {
 
 
 		CRASH_COND(Thread::get_caller_id() == Thread::get_main_id());
 		CRASH_COND(Thread::get_caller_id() == Thread::get_main_id());
@@ -2297,14 +2298,20 @@ RES ResourceFormatLoaderCSharpScript::load(const String &p_path, const String &p
 		// because this may be called by one of the editor's worker threads.
 		// because this may be called by one of the editor's worker threads.
 		// Attach this thread temporarily to reload the script.
 		// Attach this thread temporarily to reload the script.
 
 
-		MonoThread *mono_thread = mono_thread_attach(SCRIPTS_DOMAIN);
-		CRASH_COND(mono_thread == NULL);
+		if (SCRIPTS_DOMAIN) {
+			MonoThread *mono_thread = mono_thread_attach(SCRIPTS_DOMAIN);
+			CRASH_COND(mono_thread == NULL);
+			script->reload();
+			mono_thread_detach(mono_thread);
+		}
+
+	} else { // just reload it normally
+#endif
 		script->reload();
 		script->reload();
-		mono_thread_detach(mono_thread);
 
 
-	} else // just reload it normally
+#ifdef TOOLS_ENABLED
+	}
 #endif
 #endif
-	script->reload();
 
 
 	if (r_error)
 	if (r_error)
 		*r_error = OK;
 		*r_error = OK;

+ 1 - 1
modules/mono/editor/bindings_generator.cpp

@@ -730,7 +730,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
 	}
 	}
 
 
 	output.push_back(INDENT1 "public ");
 	output.push_back(INDENT1 "public ");
-	bool is_abstract = !ClassDB::can_instance(itype.name) && ClassDB::is_class_enabled(itype.name); // can_instance returns true if there's a constructor and the class is not 'disabled'
+	bool is_abstract = itype.is_object_type && !ClassDB::can_instance(itype.name) && ClassDB::is_class_enabled(itype.name); // can_instance returns true if there's a constructor and the class is not 'disabled'
 	output.push_back(itype.is_singleton ? "static class " : (is_abstract ? "abstract class " : "class "));
 	output.push_back(itype.is_singleton ? "static class " : (is_abstract ? "abstract class " : "class "));
 	output.push_back(itype.proxy_name);
 	output.push_back(itype.proxy_name);