From d75d9a6b3f33a3d901b8bc0d1d37b0f6af8d2766 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Sat, 1 Aug 2015 11:14:20 +0200 Subject: fix for 1478636 (crash on import when comments in defs) Fixed bugs: - https://launchpad.net/bugs/1478636 (bzr r14270) --- src/document.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index ebf5d312f..2ea969910 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1640,7 +1640,7 @@ void SPDocument::importDefs(SPDocument *source) prevent_id_clashes(source, this); for (std::vector::iterator defs = defsNodes.begin(); defs != defsNodes.end(); ++defs) { - importDefsNode(source, const_cast(*defs), target_defs); + importDefsNode(source, const_cast(*defs), target_defs); } } @@ -1688,11 +1688,10 @@ void SPDocument::importDefsNode(SPDocument *source, Inkscape::XML::Node *defs, I /* First pass: remove duplicates in clipboard of definitions in document */ for (Inkscape::XML::Node *def = defs->firstChild() ; def ; def = def->next()) { - + if(def->type() != Inkscape::XML::ELEMENT_NODE)continue; /* If this clipboard has been pasted into one document, and is now being pasted into another, or pasted again into the same, it will already have been processed. If we detect that then skip the rest of this pass. */ - Glib::ustring defid = def->attribute("id"); if( defid.find( DuplicateDefString ) != Glib::ustring::npos )break; @@ -1722,6 +1721,7 @@ void SPDocument::importDefsNode(SPDocument *source, Inkscape::XML::Node *defs, I /* Second pass: remove duplicates in clipboard of earlier definitions in clipboard */ for (Inkscape::XML::Node *def = defs->firstChild() ; def ; def = def->next()) { + if(def->type() != Inkscape::XML::ELEMENT_NODE)continue; Glib::ustring defid = def->attribute("id"); if( defid.find( DuplicateDefString ) != Glib::ustring::npos )continue; // this one already handled SPObject *src = source->getObjectByRepr(def); @@ -1749,6 +1749,7 @@ void SPDocument::importDefsNode(SPDocument *source, Inkscape::XML::Node *defs, I /* Final pass: copy over those parts which are not duplicates */ for (Inkscape::XML::Node *def = defs->firstChild() ; def ; def = def->next()) { + if(def->type() != Inkscape::XML::ELEMENT_NODE)continue; /* Ignore duplicate defs marked in the first pass */ Glib::ustring defid = def->attribute("id"); -- cgit v1.2.3