Mono: Do not spam script class not found error

Print this error only when trying to instantiate the script. This way we prevent errors being printed for source files which are not meant to be used as scripts.
This commit is contained in:
Ignacio Etcheverry 2018-04-24 20:42:31 +02:00
parent 89e84185e8
commit f8ce412560
1 changed files with 12 additions and 13 deletions

View File

@ -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) if (!script_class) {
return NULL; 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());
}
#ifdef DEBUG_ENABLED
else if (OS::get_singleton()->is_stdout_verbose()) {
OS::get_singleton()->print(String("Found class " + script_class->get_namespace() + "." +
script_class->get_name() + " for script " + get_path() + "\n")
.utf8());
}
#endif
valid = script_class != NULL; valid = script_class != NULL;
if (script_class) { if (script_class) {
#ifdef DEBUG_ENABLED
OS::get_singleton()->print(String("Found class " + script_class->get_namespace() + "." +
script_class->get_name() + " for script " + get_path() + "\n")
.utf8());
#endif
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);