diff options
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/packed_scene.cpp | 3 | ||||
-rw-r--r-- | scene/resources/scene_format_text.cpp | 11 |
2 files changed, 8 insertions, 6 deletions
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 5ac7946391..ac528e6659 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -1413,8 +1413,7 @@ NodePath SceneState::get_node_path(int p_idx,bool p_for_parent) const { } } - for(int i=0;i<base_path.get_name_count();i++) { - StringName sn = base_path.get_name(i); + for(int i=base_path.get_name_count()-1;i>=0;i--) { sub_path.insert(0,base_path.get_name(i)); } diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp index a734f63ac2..c7e2fc4e73 100644 --- a/scene/resources/scene_format_text.cpp +++ b/scene/resources/scene_format_text.cpp @@ -1140,7 +1140,12 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant& p_variant,b } +static String _valprop(const String& p_name) { + if (p_name.find("\"")!=-1 || p_name.find("=")!=-1 || p_name.find(" ")!=-1) + return "\""+p_name.c_escape()+"\""; + return p_name; +} Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_resource,uint32_t p_flags) { @@ -1296,7 +1301,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re String vars; VariantWriter::write_to_string(value,vars,_write_resources,this); - f->store_string(name+" = "+vars+"\n"); + f->store_string(_valprop(name)+" = "+vars+"\n"); } @@ -1320,8 +1325,6 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re Vector<StringName> groups = state->get_node_groups(i); - if (instance.is_valid()) - print_line("for path "+String(path)+" instance "+instance->get_path()); String header="[node"; header+=" name=\""+String(name)+"\""; @@ -1372,7 +1375,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re String vars; VariantWriter::write_to_string(state->get_node_property_value(i,j),vars,_write_resources,this); - f->store_string(String(state->get_node_property_name(i,j))+" = "+vars+"\n"); + f->store_string(_valprop(String(state->get_node_property_name(i,j)))+" = "+vars+"\n"); } if (state->get_node_property_count(i)) { |