Remove error when getting dependencies from tscn files in some cases, closes #3897
This commit is contained in:
parent
3754f6cd75
commit
519fce94e9
2 changed files with 35 additions and 22 deletions
|
@ -67,12 +67,17 @@ Error ResourceInteractiveLoaderText::_parse_sub_resource(VariantParser::Stream*
|
||||||
|
|
||||||
String path = local_path+"::"+itos(index);
|
String path = local_path+"::"+itos(index);
|
||||||
|
|
||||||
if (!ResourceCache::has(path)) {
|
if (!ignore_resource_parsing) {
|
||||||
r_err_str="Can't load cached sub-resource: "+path;
|
|
||||||
return ERR_PARSE_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
r_res=RES(ResourceCache::get(path));
|
if (!ResourceCache::has(path)) {
|
||||||
|
r_err_str="Can't load cached sub-resource: "+path;
|
||||||
|
return ERR_PARSE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
r_res=RES(ResourceCache::get(path));
|
||||||
|
} else {
|
||||||
|
r_res=RES();
|
||||||
|
}
|
||||||
|
|
||||||
VariantParser::get_token(p_stream,token,line,r_err_str);
|
VariantParser::get_token(p_stream,token,line,r_err_str);
|
||||||
if (token.type!=VariantParser::TK_PARENTHESIS_CLOSE) {
|
if (token.type!=VariantParser::TK_PARENTHESIS_CLOSE) {
|
||||||
|
@ -95,25 +100,29 @@ Error ResourceInteractiveLoaderText::_parse_ext_resource(VariantParser::Stream*
|
||||||
|
|
||||||
int id = token.value;
|
int id = token.value;
|
||||||
|
|
||||||
|
if (!ignore_resource_parsing) {
|
||||||
|
|
||||||
if (!ext_resources.has(id)) {
|
if (!ext_resources.has(id)) {
|
||||||
r_err_str="Can't load cached ext-resource #"+itos(id);
|
r_err_str="Can't load cached ext-resource #"+itos(id);
|
||||||
return ERR_PARSE_ERROR;
|
return ERR_PARSE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
String path = ext_resources[id].path;
|
String path = ext_resources[id].path;
|
||||||
String type = ext_resources[id].type;
|
String type = ext_resources[id].type;
|
||||||
|
|
||||||
if (path.find("://")==-1 && path.is_rel_path()) {
|
if (path.find("://")==-1 && path.is_rel_path()) {
|
||||||
// path is relative to file being loaded, so convert to a resource path
|
// path is relative to file being loaded, so convert to a resource path
|
||||||
path=Globals::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
|
path=Globals::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r_res=ResourceLoader::load(path,type);
|
r_res=ResourceLoader::load(path,type);
|
||||||
|
|
||||||
if (r_res.is_null()) {
|
if (r_res.is_null()) {
|
||||||
WARN_PRINT(String("Couldn't load external resource: "+path).utf8().get_data());
|
WARN_PRINT(String("Couldn't load external resource: "+path).utf8().get_data());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
r_res=RES();
|
||||||
}
|
}
|
||||||
|
|
||||||
VariantParser::get_token(p_stream,token,line,r_err_str);
|
VariantParser::get_token(p_stream,token,line,r_err_str);
|
||||||
|
@ -625,6 +634,7 @@ void ResourceInteractiveLoaderText::get_dependencies(FileAccess *f,List<String>
|
||||||
|
|
||||||
|
|
||||||
open(f);
|
open(f);
|
||||||
|
ignore_resource_parsing=true;
|
||||||
ERR_FAIL_COND(error!=OK);
|
ERR_FAIL_COND(error!=OK);
|
||||||
|
|
||||||
while(next_tag.name=="ext_resource") {
|
while(next_tag.name=="ext_resource") {
|
||||||
|
@ -662,6 +672,7 @@ void ResourceInteractiveLoaderText::get_dependencies(FileAccess *f,List<String>
|
||||||
Error err = VariantParser::parse_tag(&stream,lines,error_text,next_tag,&rp);
|
Error err = VariantParser::parse_tag(&stream,lines,error_text,next_tag,&rp);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
|
print_line(error_text+" - "+itos(lines));
|
||||||
error_text="Unexpected end of file";
|
error_text="Unexpected end of file";
|
||||||
_printerr();
|
_printerr();
|
||||||
error=ERR_FILE_CORRUPT;
|
error=ERR_FILE_CORRUPT;
|
||||||
|
@ -676,7 +687,7 @@ Error ResourceInteractiveLoaderText::rename_dependencies(FileAccess *p_f, const
|
||||||
|
|
||||||
open(p_f,true);
|
open(p_f,true);
|
||||||
ERR_FAIL_COND_V(error!=OK,error);
|
ERR_FAIL_COND_V(error!=OK,error);
|
||||||
|
ignore_resource_parsing=true;
|
||||||
//FileAccess
|
//FileAccess
|
||||||
|
|
||||||
FileAccess *fw = NULL;
|
FileAccess *fw = NULL;
|
||||||
|
@ -794,7 +805,7 @@ void ResourceInteractiveLoaderText::open(FileAccess *p_f,bool p_skip_first_tag)
|
||||||
|
|
||||||
stream.f=f;
|
stream.f=f;
|
||||||
is_scene=false;
|
is_scene=false;
|
||||||
|
ignore_resource_parsing=false;
|
||||||
resource_current=0;
|
resource_current=0;
|
||||||
|
|
||||||
|
|
||||||
|
@ -879,6 +890,8 @@ String ResourceInteractiveLoaderText::recognize(FileAccess *p_f) {
|
||||||
|
|
||||||
stream.f=f;
|
stream.f=f;
|
||||||
|
|
||||||
|
ignore_resource_parsing=true;
|
||||||
|
|
||||||
|
|
||||||
VariantParser::Tag tag;
|
VariantParser::Tag tag;
|
||||||
Error err = VariantParser::parse_tag(&stream,lines,error_text,tag);
|
Error err = VariantParser::parse_tag(&stream,lines,error_text,tag);
|
||||||
|
@ -1296,7 +1309,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
|
||||||
if ((PE->get().usage&PROPERTY_USAGE_STORE_IF_NONZERO && value.is_zero())||(PE->get().usage&PROPERTY_USAGE_STORE_IF_NONONE && value.is_one()) )
|
if ((PE->get().usage&PROPERTY_USAGE_STORE_IF_NONZERO && value.is_zero())||(PE->get().usage&PROPERTY_USAGE_STORE_IF_NONONE && value.is_one()) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (PE->get().type==Variant::OBJECT && value.is_zero() && (!PE->get().usage&PROPERTY_USAGE_STORE_IF_NULL))
|
if (PE->get().type==Variant::OBJECT && value.is_zero() && !(PE->get().usage&PROPERTY_USAGE_STORE_IF_NULL))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
String vars;
|
String vars;
|
||||||
|
|
|
@ -56,7 +56,7 @@ class ResourceInteractiveLoaderText : public ResourceInteractiveLoader {
|
||||||
bool is_scene;
|
bool is_scene;
|
||||||
String res_type;
|
String res_type;
|
||||||
|
|
||||||
|
bool ignore_resource_parsing;
|
||||||
|
|
||||||
// Map<String,String> remaps;
|
// Map<String,String> remaps;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue