From 54f21698664f3b4ae65a4ece376dc404212a2639 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 31 Jan 2014 22:56:58 +0100 Subject: Do not throw TypeNotRegistered exceptions for now, since they interfere with debugging via 'catch throw'. (bzr r12991) --- src/sp-object.cpp | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'src/sp-object.cpp') diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 0e6eef6ae..764b5f260 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -585,23 +585,22 @@ SPObject *SPObject::get_child_by_repr(Inkscape::XML::Node *repr) void SPObject::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { SPObject* object = this; - try { - const std::string typeString = NodeTraits::get_type_string(*child); + const std::string type_string = NodeTraits::get_type_string(*child); - SPObject* ochild = SPFactory::instance().createObject(typeString); - - SPObject *prev = ref ? object->get_child_by_repr(ref) : NULL; - object->attach(ochild, prev); - sp_object_unref(ochild, NULL); - - ochild->invoke_build(object->document, child, object->cloned); - } catch (const FactoryExceptions::TypeNotRegistered& e) { + SPObject* ochild = SPFactory::instance().createObject(type_string); + if (ochild == NULL) { // Currenty, there are many node types that do not have // corresponding classes in the SPObject tree. // (rdf:RDF, inkscape:clipboard, ...) // Thus, simply ignore this case for now. return; } + + SPObject *prev = ref ? object->get_child_by_repr(ref) : NULL; + object->attach(ochild, prev); + sp_object_unref(ochild, NULL); + + ochild->invoke_build(object->document, child, object->cloned); } void SPObject::release() { @@ -645,21 +644,20 @@ void SPObject::build(SPDocument *document, Inkscape::XML::Node *repr) { object->readAttr("inkscape:collect"); for (Inkscape::XML::Node *rchild = repr->firstChild() ; rchild != NULL; rchild = rchild->next()) { - try { - const std::string typeString = NodeTraits::get_type_string(*rchild); - - SPObject* child = SPFactory::instance().createObject(typeString); + const std::string typeString = NodeTraits::get_type_string(*rchild); - object->attach(child, object->lastChild()); - sp_object_unref(child, NULL); - child->invoke_build(document, rchild, object->cloned); - } catch (const FactoryExceptions::TypeNotRegistered& e) { + SPObject* child = SPFactory::instance().createObject(typeString); + if (child == NULL) { // Currenty, there are many node types that do not have // corresponding classes in the SPObject tree. // (rdf:RDF, inkscape:clipboard, ...) // Thus, simply ignore this case for now. continue; } + + object->attach(child, object->lastChild()); + sp_object_unref(child, NULL); + child->invoke_build(document, rchild, object->cloned); } } -- cgit v1.2.3 From 77c1e38b02cfc327e161afffd590473bcc7d4526 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 24 Mar 2014 20:53:16 +0100 Subject: noop: code legibilty (bzr r13197) --- src/sp-object.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/sp-object.cpp') diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 764b5f260..c3ce3606b 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -967,31 +967,29 @@ static gchar const *sp_xml_get_space_string(unsigned int space) } Inkscape::XML::Node* SPObject::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { - SPObject* object = this; - if (!repr && (flags & SP_OBJECT_WRITE_BUILD)) { - repr = object->getRepr()->duplicate(doc); + repr = this->getRepr()->duplicate(doc); if (!( flags & SP_OBJECT_WRITE_EXT )) { repr->setAttribute("inkscape:collect", NULL); } } else { - repr->setAttribute("id", object->getId()); + repr->setAttribute("id", this->getId()); - if (object->xml_space.set) { + if (this->xml_space.set) { char const *xml_space; - xml_space = sp_xml_get_space_string(object->xml_space.value); + xml_space = sp_xml_get_space_string(this->xml_space.value); repr->setAttribute("xml:space", xml_space); } if ( flags & SP_OBJECT_WRITE_EXT && - object->collectionPolicy() == SPObject::ALWAYS_COLLECT ) + this->collectionPolicy() == SPObject::ALWAYS_COLLECT ) { repr->setAttribute("inkscape:collect", "always"); } else { repr->setAttribute("inkscape:collect", NULL); } - SPStyle const *const obj_style = object->style; + SPStyle const *const obj_style = this->style; if (obj_style) { gchar *s = sp_style_write_string(obj_style, SP_STYLE_FLAG_IFSET); @@ -1028,7 +1026,7 @@ Inkscape::XML::Node* SPObject::write(Inkscape::XML::Document *doc, Inkscape::XML g_warning("Item's style is NULL; repr style attribute is %s", style_str); } - /** \note We treat object->style as authoritative. Its effects have + /** \note We treat this->style as authoritative. Its effects have * been written to the style attribute above; any properties that are * unset we take to be deliberately unset (e.g. so that clones can * override the property). @@ -1038,7 +1036,7 @@ Inkscape::XML::Node* SPObject::write(Inkscape::XML::Document *doc, Inkscape::XML * possibly we should write property attributes instead of a style * attribute. */ - sp_style_unset_property_attrs (object); + sp_style_unset_property_attrs (this); } return repr; -- cgit v1.2.3 From c12885a05f335fea74ba4239e3d0bebe220cee8d Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 24 Mar 2014 20:58:19 +0100 Subject: spobject: extra careful, check that repr is not nullptr (bzr r13198) --- src/sp-object.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-object.cpp') diff --git a/src/sp-object.cpp b/src/sp-object.cpp index c3ce3606b..be3a1ab9d 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -972,7 +972,7 @@ Inkscape::XML::Node* SPObject::write(Inkscape::XML::Document *doc, Inkscape::XML if (!( flags & SP_OBJECT_WRITE_EXT )) { repr->setAttribute("inkscape:collect", NULL); } - } else { + } else if (repr) { repr->setAttribute("id", this->getId()); if (this->xml_space.set) { -- cgit v1.2.3