From: dooglus Date: Thu, 17 Jan 2008 00:16:40 +0000 (+0000) Subject: When loading LinkableValueNode from a .sif file, accept any of the various names... X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=9b60c394e7f36df4c48ca84d87c7796ea15dcdb8;p=synfig.git When loading LinkableValueNode from a .sif file, accept any of the various names for the links, rather than just the one returned by link_name(int). The specialised code for the 'composite' ValueNode needs the same doing for it still. git-svn-id: http://svn.voria.com/code@1387 1f10aa63-cdf2-0310-b900-c93c546f37ac --- diff --git a/synfig-core/trunk/src/synfig/loadcanvas.cpp b/synfig-core/trunk/src/synfig/loadcanvas.cpp index fc6fbee..93dbd44 100644 --- a/synfig-core/trunk/src/synfig/loadcanvas.cpp +++ b/synfig-core/trunk/src/synfig/loadcanvas.cpp @@ -1139,31 +1139,39 @@ CanvasParser::parse_linkable_value_node(xmlpp::Element *element,Canvas::Handle c value_node->set_root_canvas(canvas->get_root()); int i; - for(i=0;ilink_count();i++) + String id, name; + xmlpp::Element::AttributeList attrib_list(element->get_attributes()); + for(xmlpp::Element::AttributeList::iterator iter = attrib_list.begin(); iter != attrib_list.end(); iter++) { - if(element->get_attribute(value_node->link_name(i))) + name = (*iter)->get_name(); + id = (*iter)->get_value(); + + if (name == "guid" || name == "id" || name == "type") + continue; + try { - String id(element->get_attribute(value_node->link_name(i))->get_value()); - - if(!value_node->set_link(i, - canvas->surefind_value_node( - id - ) - ) - ) error(element,strprintf(_("Unable to set link \"%s\" to ValueNode \"%s\" (link #%d in \"%s\")"),value_node->link_name(i).c_str(),id.c_str(),i,value_node->get_name().c_str())); + i = value_node->get_link_index_from_name(name); + + if(!value_node->set_link(i, canvas->surefind_value_node(id))) + error(element,strprintf(_("Unable to set link \"%s\" to ValueNode \"%s\" (link #%d in \"%s\")"),value_node->link_name(i).c_str(),id.c_str(),i,value_node->get_name().c_str())); + else + printf(" composite: set '%s'\n", name.c_str()); + } + catch (Exception::BadLinkName) + { + error(element,"Bad link name " + name); } catch(Exception::IDNotFound) { - error(element,"Unable to resolve "+element->get_attribute(value_node->link_name(i))->get_value()); + error(element,"Unable to resolve " + id); } catch(Exception::FileNotFound) { - error(element,"Unable to open file referenced in "+element->get_attribute(value_node->link_name(i))->get_value()); + error(element,"Unable to open file referenced in " + id); } catch(...) { - error(element,strprintf(_("Unknown Exception thrown when referencing ValueNode \"%s\""), - element->get_attribute(value_node->link_name(i))->get_value().c_str())); + error(element,strprintf(_("Unknown Exception thrown when referencing ValueNode \"%s\""), id.c_str())); throw; } }