From 3e075e587aaa712efb1704478cd1a75131882889 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Mon, 2 Oct 2017 23:30:11 +0200 Subject: third batch --- src/text-chemistry.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/text-chemistry.cpp') diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index bde269de7..2c84a00f3 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -140,9 +140,9 @@ text_put_on_path() text->getRepr()->setAttribute("transform", NULL); // make a list of text children - GSList *text_reprs = NULL; + std::vector text_reprs; for(auto& o: text->children) { - text_reprs = g_slist_prepend(text_reprs, o.getRepr()); + text_reprs.push_back(o.getRepr()); } // create textPath and put it into the text @@ -158,9 +158,9 @@ text_put_on_path() } text->getRepr()->addChild(textpath, NULL); - for ( GSList *i = text_reprs ; i ; i = i->next ) { + for (auto i=text_reprs.rbegin();i!=text_reprs.rend();++i) { // Make a copy of each text child - Inkscape::XML::Node *copy = ((Inkscape::XML::Node *) i->data)->duplicate(xml_doc); + Inkscape::XML::Node *copy = (*i)->duplicate(xml_doc); // We cannot have multiline in textpath, so remove line attrs from tspans if (!strcmp(copy->name(), "svg:tspan")) { copy->setAttribute("sodipodi:role", NULL); @@ -168,7 +168,7 @@ text_put_on_path() copy->setAttribute("y", NULL); } // remove the old repr from under text - text->getRepr()->removeChild(reinterpret_cast(i->data)); + text->getRepr()->removeChild(*i); // put its copy into under textPath textpath->addChild(copy, NULL); // fixme: copy id } @@ -179,7 +179,6 @@ text_put_on_path() DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT, _("Put text on path")); - g_slist_free(text_reprs); } void @@ -393,7 +392,7 @@ text_unflow () } std::vector new_objs; - GSList *old_objs = NULL; + std::vector old_objs; auto items = selection->items(); for(auto i=items.begin();i!=items.end();++i){ @@ -444,7 +443,7 @@ text_unflow () text->_adjustFontsizeRecursive(text, ex); new_objs.push_back((SPItem*)text_object); - old_objs = g_slist_prepend (old_objs, flowtext); + old_objs.push_back(flowtext); Inkscape::GC::release(rtext); Inkscape::GC::release(rtspan); @@ -454,12 +453,10 @@ text_unflow () selection->clear(); reverse(new_objs.begin(),new_objs.end()); selection->setList(new_objs); - for (GSList *i = old_objs; i; i = i->next) { - SP_OBJECT(i->data)->deleteObject (true); + for (auto i:old_objs) { + i->deleteObject (true); } - g_slist_free (old_objs); - DocumentUndo::done(doc, SP_VERB_CONTEXT_TEXT, _("Unflow flowed text")); } -- cgit v1.2.3