From ffad9dc2db767446728e9a95bc1ae6141ecc1077 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Wed, 28 Dec 2022 13:27:01 +0100 Subject: [PATCH 1/2] Remove duplicate code from extensions handling --- src/extension/implementation/script.cpp | 52 +------------------------ 1 file changed, 2 insertions(+), 50 deletions(-) diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index f7e60af3b1..e249b8aa54 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -625,6 +625,8 @@ void Script::_change_extension(Inkscape::Extension::Extension *module, SPDocumen if (mydoc) { mydoc->changeFilenameAndHrefs(doc->getDocumentFilename()); doc->emitReconstructionStart(); + //delete doc; + //doc = mydoc->copy().get(); copy_doc(doc->getReprRoot(), mydoc->getReprRoot()); doc->emitReconstructionFinish(); mydoc->release(); @@ -661,56 +663,6 @@ void Script::copy_doc (Inkscape::XML::Node * oldroot, Inkscape::XML::Node * newr g_warning("Error on copy_doc: NULL pointer input."); return; } - - // For copying attributes in root and in namedview - std::vector attribs; - - // Must explicitly copy root attributes. This must be done first since - // copying grid lines calls "SPGuide::set()" which needs to know the - // width, height, and viewBox of the root element. - - // Make a list of all attributes of the old root node. - for (const auto & iter : oldroot->attributeList()) { - attribs.push_back(g_quark_to_string(iter.key)); - } - - // Delete the attributes of the old root node. - for (auto attrib : attribs) { - oldroot->removeAttribute(attrib); - } - - // Set the new attributes. - for (const auto & iter : newroot->attributeList()) { - gchar const *name = g_quark_to_string(iter.key); - oldroot->setAttribute(name, newroot->attribute(name)); - } - - // Question: Why is the "sodipodi:namedview" special? Treating it as a normal - // element results in crashes. - // Seems to be a bug: - // http://inkscape.13.x6.nabble.com/Effect-that-modifies-the-document-properties-tt2822126.html - - std::vector delete_list; - - // Make list - for (Inkscape::XML::Node * child = oldroot->firstChild(); - child != nullptr; - child = child->next()) { - if (!strcmp("sodipodi:namedview", child->name())) { - for (Inkscape::XML::Node * oldroot_namedview_child = child->firstChild(); - oldroot_namedview_child != nullptr; - oldroot_namedview_child = oldroot_namedview_child->next()) { - delete_list.push_back(oldroot_namedview_child); - } - break; - } - } - - // Unparent (delete) - for (auto & i : delete_list) { - sp_repr_unparent(i); - } - attribs.clear(); oldroot->mergeFrom(newroot, "id", true, true); } -- GitLab From 6d66be073428777f00e29c484be5f03c0c60480c Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Wed, 28 Dec 2022 13:01:28 +0000 Subject: [PATCH 2/2] remove not used comments --- src/extension/implementation/script.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index e249b8aa54..0aae58d0cb 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -625,8 +625,6 @@ void Script::_change_extension(Inkscape::Extension::Extension *module, SPDocumen if (mydoc) { mydoc->changeFilenameAndHrefs(doc->getDocumentFilename()); doc->emitReconstructionStart(); - //delete doc; - //doc = mydoc->copy().get(); copy_doc(doc->getReprRoot(), mydoc->getReprRoot()); doc->emitReconstructionFinish(); mydoc->release(); -- GitLab