From fc4b076593df6f406974dd502ca09c1b865e6f72 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 3 Jun 2016 09:50:21 +0200 Subject: Fix guide placement when guides are generated by a template with width/height/viewBox different from default SVG file. (bzr r14947) --- src/extension/implementation/script.cpp | 51 +++++++++++++++++---------------- 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'src/extension/implementation/script.cpp') diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 9aaf4b952..01323bee2 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -808,15 +808,17 @@ void Script::effect(Inkscape::Extension::Effect *module, \param oldroot The root node of the old (destination) document. \param newroot The root node of the new (source) document. - This function first deletes all the elements in the old document by + This function first deletes all the root attributes in the old document followed + by copying all the root attributes from the new document to the old document. + + It then deletes all the elements in the old document by making two pass, the first to create a list of the old elements and the second to actually delete them. This two pass approach removes issues with the list being change while parsing through it... lots of nasty bugs. Then, it copies all the element in the new document into the old document. - Finally, it replaces the attributes in the root element of the old document - by the attributes in root of the new document. + Finally, it copies the attributes in namedview. */ void Script::copy_doc (Inkscape::XML::Node * oldroot, Inkscape::XML::Node * newroot) { @@ -829,6 +831,28 @@ void Script::copy_doc (Inkscape::XML::Node * oldroot, Inkscape::XML::Node * newr // For copying attributes in root and in namedview using Inkscape::Util::List; using Inkscape::XML::AttributeRecord; + 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 (List iter = oldroot->attributeList(); iter; ++iter) { + attribs.push_back(g_quark_to_string(iter->key)); + } + + // Delete the attributes of the old root node. + for (std::vector::const_iterator it = attribs.begin(); it != attribs.end(); ++it) { + oldroot->setAttribute(*it, NULL); + } + + // Set the new attributes. + for (List iter = newroot->attributeList(); iter; ++iter) { + 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 // elmement results in crashes. @@ -882,30 +906,9 @@ void Script::copy_doc (Inkscape::XML::Node * oldroot, Inkscape::XML::Node * newr } } - std::vector attribs; - - // Must explicitly copy root attributes. - - // Make a list of all attributes of the old root node. - for (List iter = oldroot->attributeList(); iter; ++iter) { - attribs.push_back(g_quark_to_string(iter->key)); - } - - // Delete the attributes of the old root node. - for (std::vector::const_iterator it = attribs.begin(); it != attribs.end(); ++it) { - oldroot->setAttribute(*it, NULL); - } - - // Set the new attributes. - for (List iter = newroot->attributeList(); iter; ++iter) { - gchar const *name = g_quark_to_string(iter->key); - oldroot->setAttribute(name, newroot->attribute(name)); - } - attribs.clear(); // Must explicitly copy namedview attributes. - // Make a list of all attributes of the old namedview node. for (List iter = oldroot_namedview->attributeList(); iter; ++iter) { attribs.push_back(g_quark_to_string(iter->key)); -- cgit v1.2.3 From 1636c1dd1651780d01759676b194312529f211f7 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Sat, 25 Jun 2016 22:24:26 +0200 Subject: Moved next functions, added namespace, renamed range functions (bzr r14954.1.10) --- src/extension/implementation/script.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/extension/implementation/script.cpp') diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 01323bee2..0acc99aed 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -690,7 +690,7 @@ void Script::effect(Inkscape::Extension::Effect *module, } std::vector selected = - desktop->getSelection()->itemList(); //desktop should not be NULL since doc was checked and desktop is a casted pointer + desktop->getSelection()->items(); //desktop should not be NULL since doc was checked and desktop is a casted pointer for(std::vector::const_iterator x = selected.begin(); x != selected.end(); ++x){ Glib::ustring selected_id; selected_id += "--id="; -- cgit v1.2.3 From cebbe5b970cba85a5e21f8347f0a20e78351d394 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 28 Jul 2016 11:22:07 +0100 Subject: extensions: Drop GTKMM2 fallbacks (bzr r15023.2.5) --- src/extension/implementation/script.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/extension/implementation/script.cpp') diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 01323bee2..72a189c3f 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -942,11 +942,7 @@ void Script::checkStderr (const Glib::ustring &data, GtkWidget *dlg = GTK_WIDGET(warning.gobj()); sp_transientize(dlg); -#if WITH_GTKMM_3_0 - Gtk::Box * vbox = warning.get_content_area(); -#else - Gtk::Box * vbox = warning.get_vbox(); -#endif + auto vbox = warning.get_content_area(); /* Gtk::TextView * textview = new Gtk::TextView(Gtk::TextBuffer::create()); */ Gtk::TextView * textview = new Gtk::TextView(); -- cgit v1.2.3 From a8d79dede01f2d3b38ea375bca310cd3f25796d1 Mon Sep 17 00:00:00 2001 From: peregrine Date: Wed, 8 Feb 2017 00:01:27 +0100 Subject: fix two memory leaks Fixed bugs: - https://launchpad.net/bugs/1662686 - https://launchpad.net/bugs/1662683 (bzr r15493) --- src/extension/implementation/script.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/extension/implementation/script.cpp') diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index d2319c2e0..b1058d415 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -963,6 +963,9 @@ void Script::checkStderr (const Glib::ustring &data, warning.run(); + delete textview; + delete scrollwindow; + return; } -- cgit v1.2.3