X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Floadcanvas.cpp;h=49cf6bcc131fbbc0bccc9e16035afd43df91603b;hb=82f8b521a55c8985cd0189c9c71940a7312eccaa;hp=f4a91c84ec31cca996a1943cb7222655d1bcd27d;hpb=bf92e1e2c959ab1fb668fa5a8274004a6f30a140;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/loadcanvas.cpp b/synfig-core/trunk/src/synfig/loadcanvas.cpp index f4a91c8..49cf6bc 100644 --- a/synfig-core/trunk/src/synfig/loadcanvas.cpp +++ b/synfig-core/trunk/src/synfig/loadcanvas.cpp @@ -6,6 +6,7 @@ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2007 Chris Moore ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -290,6 +291,15 @@ CanvasParser::parse_integer(xmlpp::Element *element) return atoi(val.c_str()); } +// see 'minor hack' at the end of parse_vector() below +// making this 'static' to give it file local scope +// stops it working (where working means working around +// bug #1509627) +Vector &canvas_parser_vector_id(Vector &vector) +{ + return vector; +} + Vector CanvasParser::parse_vector(xmlpp::Element *element) { @@ -332,7 +342,12 @@ CanvasParser::parse_vector(xmlpp::Element *element) else error_unexpected_element(child,child->get_name()); } - return vect; + // Minor hack - gcc 4.1.2 and earlier think that we're not using + // 'vect' and optimize it out at -O2 and higher. This convinces + // them that we are really using it. + return canvas_parser_vector_id(vect); + // When the bug is fixed, we can just do this instead: + // return vect; } Color @@ -1040,194 +1055,6 @@ CanvasParser::parse_animated(xmlpp::Element *element,Canvas::Handle canvas) return value_node; } -handle -CanvasParser::parse_subtract(xmlpp::Element *element,Canvas::Handle canvas) -{ - assert(element->get_name()=="subtract"); - - handle value_node; - handle lhs,rhs,scalar; - - if(element->get_attribute("type")) - { - ValueBase::Type type=ValueBase::ident_type(element->get_attribute("type")->get_value()); - - if(!type) - { - error(element,"Bad type in "); - return ValueNode_Subtract::Handle(); - } - value_node=ValueNode_Subtract::create(type); - } - else - value_node=ValueNode_Subtract::create(); - - if(!value_node) - { - error(element,strprintf(_("Unable to create "))); - return handle(); - } - - //if(element->get_attribute("scalar")) - //{ - // value_node->set_scalar(atof(element->get_attribute("scalar")->get_value().c_str())); - //} - - try - { - if(element->get_attribute("scalar")) - { - // This is for compatibility with older versions of the file format - String value(element->get_attribute("scalar")->get_value()); - if((value[0]<='9' && value[0]>='0') || value[0]=='-') - { - warning(element, _("Use of a real value where the ID should be is deprecated")); - value_node->set_scalar(atof(value.c_str())); - } - else - value_node->set_scalar(canvas->surefind_value_node(value)); - scalar=value_node->get_scalar(); - } - - if(element->get_attribute("lhs")) - { - lhs=canvas->surefind_value_node(element->get_attribute("lhs")->get_value()); - value_node->set_lhs(lhs); - } - - if(element->get_attribute("rhs")) - { - rhs=canvas->surefind_value_node(element->get_attribute("rhs")->get_value()); - value_node->set_rhs(rhs); - } - } - catch (Exception::IDNotFound) - { - error(element,"attribute in references unknown ID"); - } - catch (Exception::FileNotFound) - { - error(element,"Unable to open external file referenced in ID"); - } - - xmlpp::Element::NodeList list = element->get_children(); - for(xmlpp::Element::NodeList::iterator iter = list.begin(); iter != list.end(); ++iter) - { - xmlpp::Element *child(dynamic_cast(*iter)); - if(!child) - continue; - else - if(child->get_name()=="lhs") - { - if(lhs) - { - error(child,"LHS component of already defined!"); - continue; - } - - xmlpp::Element::NodeList list = child->get_children(); - xmlpp::Element::NodeList::iterator iter; - - // Search for the first non-text XML element - for(iter = list.begin(); iter != list.end(); ++iter) - if(dynamic_cast(*iter)) break; - - if(iter==list.end()) - { - error(child,_(" is missing its contents")); - continue; - } - - lhs=parse_value_node(dynamic_cast(*iter),canvas); - - if(lhs) - value_node->set_lhs(lhs); - else - { - error((*iter),"Parse of LHS ValueNode failed"); - } - - // \todo do a search for more elements and warn if they are found - } - else - if(child->get_name()=="rhs") - { - if(rhs) - { - error(child,"RHS component of already defined!"); - continue; - } - - xmlpp::Element::NodeList list = child->get_children(); - xmlpp::Element::NodeList::iterator iter; - - // Search for the first non-text XML element - for(iter = list.begin(); iter != list.end(); ++iter) - if(dynamic_cast(*iter)) break; - - if(iter==list.end()) - { - error(child,_(" is missing its contents")); - continue; - } - - rhs=parse_value_node(dynamic_cast(*iter),canvas); - - if(rhs) - value_node->set_rhs(rhs); - else - { - error((*iter),"Parse of RHS ValueNode failed"); - } - - // \todo do a search for more elements and warn if they are found - } - else - if(child->get_name()=="scalar") - { - if(scalar) - { - error(child,"scalar component of already defined!"); - continue; - } - - xmlpp::Element::NodeList list = child->get_children(); - xmlpp::Element::NodeList::iterator iter; - - // Search for the first non-text XML element - for(iter = list.begin(); iter != list.end(); ++iter) - if(dynamic_cast(*iter)) break; - - if(iter==list.end()) - { - error(child,_(" is missing its contents")); - continue; - } - - scalar=parse_value_node(dynamic_cast(*iter),canvas); - - if(scalar) - value_node->set_scalar(scalar); - else - { - error((*iter),"Parse of scalar ValueNode failed"); - } - - // \todo do a search for more elements and warn if they are found - } - else - error_unexpected_element(child,child->get_name()); - } - - if(!value_node->get_rhs() || !value_node->get_lhs() || !value_node->get_scalar()) - error(element," is missing LHS, RHS, or SCALAR"); - - if(value_node->get_rhs() == value_node->get_lhs()) - warning(element,"LHS is equal to RHS in , so this value_node will always be zero!"); - - return value_node; -} - etl::handle CanvasParser::parse_linkable_value_node(xmlpp::Element *element,Canvas::Handle canvas) { @@ -1723,7 +1550,7 @@ CanvasParser::parse_value_node(xmlpp::Element *element,Canvas::Handle canvas) return value_node; } - // If ValueBase::ident_type() recognises the name, then we know it's a ValueBase + // If ValueBase::ident_type() recognizes the name, then we know it's a ValueBase if(element->get_name()!="canvas" && ValueBase::ident_type(element->get_name())) { ValueBase data=parse_value(element,canvas); @@ -1745,9 +1572,6 @@ CanvasParser::parse_value_node(xmlpp::Element *element,Canvas::Handle canvas) if(element->get_name()=="hermite" || element->get_name()=="animated") value_node=parse_animated(element,canvas); else - if(element->get_name()=="subtract") - value_node=parse_subtract(element,canvas); - else if(element->get_name()=="composite") value_node=parse_composite(element,canvas); else @@ -1932,7 +1756,7 @@ CanvasParser::parse_layer(xmlpp::Element *element,Canvas::Handle canvas) continue; } - // If we recognise the element name as a + // If we recognize the element name as a // ValueBase, then treat is at one if(/*(*iter)->get_name()!="canvas" && */ValueBase::ident_type((*iter)->get_name()) && !dynamic_cast(*iter)->get_attribute("guid")) { @@ -2165,7 +1989,7 @@ CanvasParser::parse_canvas(xmlpp::Element *element,Canvas::Handle parent,bool in // If we don't have any name, warn if(list.empty()) - warning(child,_("blank \"name\" entitity")); + warning(child,_("blank \"name\" entity")); string tmp; for(xmlpp::Element::NodeList::iterator iter = list.begin(); iter != list.end(); ++iter) @@ -2180,7 +2004,7 @@ CanvasParser::parse_canvas(xmlpp::Element *element,Canvas::Handle parent,bool in // If we don't have any description, warn if(list.empty()) - warning(child,_("blank \"desc\" entitity")); + warning(child,_("blank \"desc\" entity")); string tmp; for(xmlpp::Element::NodeList::iterator iter = list.begin(); iter != list.end(); ++iter) @@ -2195,7 +2019,7 @@ CanvasParser::parse_canvas(xmlpp::Element *element,Canvas::Handle parent,bool in // If we don't have any description, warn if(list.empty()) - warning(child,_("blank \"author\" entitity")); + warning(child,_("blank \"author\" entity")); string tmp; for(xmlpp::Element::NodeList::iterator iter = list.begin(); iter != list.end(); ++iter) @@ -2220,7 +2044,17 @@ CanvasParser::parse_canvas(xmlpp::Element *element,Canvas::Handle parent,bool in if(canvas->value_node_list().placeholder_count()) { - error(element,strprintf(_("Canvas %s has undefined ValueNodes"),canvas->get_id().c_str())); + String nodes; + for (ValueNodeList::const_iterator iter = canvas->value_node_list().begin(); iter != canvas->value_node_list().end(); iter++) + if(PlaceholderValueNode::Handle::cast_dynamic(*iter)) + { + if (nodes != "") nodes += ", "; + nodes += "'" + (*iter)->get_id() + "'"; + } + error(element,strprintf(_("Canvas '%s' has undefined %s: %s"), + canvas->get_id().c_str(), + canvas->value_node_list().placeholder_count() == 1 ? _("ValueNode") : _("ValueNodes"), + nodes.c_str())); } return canvas; @@ -2235,7 +2069,6 @@ CanvasParser::parse_from_file(const String &file) Canvas::Handle CanvasParser::parse_from_file_as(const String &file_,const String &as_) { - CHECK_EXPIRE_TIME(); try { ChangeLocale change_locale(LC_NUMERIC, "C"); @@ -2296,8 +2129,6 @@ CanvasParser::parse_from_file_as(const String &file_,const String &as_) Canvas::Handle CanvasParser::parse_from_string(const String &data) { - CHECK_EXPIRE_TIME(); - try { ChangeLocale change_locale(LC_NUMERIC, "C");