From a7f2b2ba3f13ceb60376802f4a31e104153839e8 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Tue, 17 Feb 2015 03:00:37 +0100 Subject: At first, I was thinking "I just have to go to the selection file, and change that GSList* with a std::list, then resolve the few problems" So, i tried that. And I will continue tomorrow, and the days after, on and on. (bzr r13922.1.1) --- src/vanishing-point.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/vanishing-point.cpp') diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp index b62aacbc5..98a3eaa67 100644 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@ -256,8 +256,9 @@ VanishingPoint::set_pos(Proj::Pt2 const &pt) { std::list VanishingPoint::selectedBoxes(Inkscape::Selection *sel) { std::list sel_boxes; - for (GSList const* i = sel->itemList(); i != NULL; i = i->next) { - SPItem *item = static_cast(i->data); + SelContainer itemlist=sel->itemList(); + for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + SPItem *item = static_cast(*i); SPBox3D *box = dynamic_cast(item); if (box && this->hasBox(box)) { sel_boxes.push_back(box); @@ -395,8 +396,9 @@ VPDragger::VPsOfSelectedBoxes() { VanishingPoint *vp; // FIXME: Should we take the selection from the parent VPDrag? I guess it shouldn't make a difference. Inkscape::Selection *sel = SP_ACTIVE_DESKTOP->getSelection(); - for (GSList const* i = sel->itemList(); i != NULL; i = i->next) { - SPItem *item = static_cast(i->data); + SelContainer itemlist=sel->itemList(); + for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + SPItem *item = static_cast(*i); SPBox3D *box = dynamic_cast(item); if (box) { vp = this->findVPWithBox(box); @@ -577,8 +579,9 @@ VPDrag::updateDraggers () g_return_if_fail (this->selection != NULL); - for (GSList const* i = this->selection->itemList(); i != NULL; i = i->next) { - SPItem *item = static_cast(i->data); + SelContainer itemlist=this->selection->itemList(); + for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + SPItem *item = static_cast(*i); SPBox3D *box = dynamic_cast(item); if (box) { VanishingPoint vp; @@ -609,8 +612,9 @@ VPDrag::updateLines () g_return_if_fail (this->selection != NULL); - for (GSList const* i = this->selection->itemList(); i != NULL; i = i->next) { - SPItem *item = static_cast(i->data); + SelContainer itemlist=this->selection->itemList(); + for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + SPItem *item = static_cast(*i); SPBox3D *box = dynamic_cast(item); if (box) { this->drawLinesForFace (box, Proj::X); @@ -626,11 +630,11 @@ VPDrag::updateBoxHandles () // FIXME: Is there a way to update the knots without accessing the // (previously) statically linked function KnotHolder::update_knots? - GSList *sel = (GSList *) selection->itemList(); - if (!sel) + SelContainer sel = selection->itemList(); + if (sel.empty()) return; // no selection - if (g_slist_length (sel) > 1) { + if (sel.size() > 1) { // Currently we only show handles if a single box is selected return; } -- cgit v1.2.3 From 5fd00cab14d48beaf2279a2b8f3ad5b02b76c87b Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Thu, 19 Feb 2015 04:25:21 +0100 Subject: Put a few std::vector (bzr r13922.1.5) --- src/vanishing-point.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/vanishing-point.cpp') diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp index 98a3eaa67..770845f38 100644 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@ -256,8 +256,8 @@ VanishingPoint::set_pos(Proj::Pt2 const &pt) { std::list VanishingPoint::selectedBoxes(Inkscape::Selection *sel) { std::list sel_boxes; - SelContainer itemlist=sel->itemList(); - for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + std::vector itemlist=sel->itemList(); + for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { SPItem *item = static_cast(*i); SPBox3D *box = dynamic_cast(item); if (box && this->hasBox(box)) { @@ -396,8 +396,8 @@ VPDragger::VPsOfSelectedBoxes() { VanishingPoint *vp; // FIXME: Should we take the selection from the parent VPDrag? I guess it shouldn't make a difference. Inkscape::Selection *sel = SP_ACTIVE_DESKTOP->getSelection(); - SelContainer itemlist=sel->itemList(); - for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + std::vector itemlist=sel->itemList(); + for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { SPItem *item = static_cast(*i); SPBox3D *box = dynamic_cast(item); if (box) { @@ -579,8 +579,8 @@ VPDrag::updateDraggers () g_return_if_fail (this->selection != NULL); - SelContainer itemlist=this->selection->itemList(); - for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + std::vector itemlist=this->selection->itemList(); + for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { SPItem *item = static_cast(*i); SPBox3D *box = dynamic_cast(item); if (box) { @@ -612,8 +612,8 @@ VPDrag::updateLines () g_return_if_fail (this->selection != NULL); - SelContainer itemlist=this->selection->itemList(); - for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + std::vector itemlist=this->selection->itemList(); + for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { SPItem *item = static_cast(*i); SPBox3D *box = dynamic_cast(item); if (box) { @@ -630,7 +630,7 @@ VPDrag::updateBoxHandles () // FIXME: Is there a way to update the knots without accessing the // (previously) statically linked function KnotHolder::update_knots? - SelContainer sel = selection->itemList(); + std::vector sel = selection->itemList(); if (sel.empty()) return; // no selection -- cgit v1.2.3 From 9a7fa4d1899d30ec745107823f307b2a0bf3172f Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Fri, 27 Feb 2015 03:10:36 +0100 Subject: corrected the casts (hopefully) (bzr r13922.1.10) --- src/vanishing-point.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/vanishing-point.cpp') diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp index 770845f38..46f895c06 100644 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@ -258,7 +258,7 @@ VanishingPoint::selectedBoxes(Inkscape::Selection *sel) { std::list sel_boxes; std::vector itemlist=sel->itemList(); for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { - SPItem *item = static_cast(*i); + SPItem *item = *i; SPBox3D *box = dynamic_cast(item); if (box && this->hasBox(box)) { sel_boxes.push_back(box); @@ -398,7 +398,7 @@ VPDragger::VPsOfSelectedBoxes() { Inkscape::Selection *sel = SP_ACTIVE_DESKTOP->getSelection(); std::vector itemlist=sel->itemList(); for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { - SPItem *item = static_cast(*i); + SPItem *item = *i; SPBox3D *box = dynamic_cast(item); if (box) { vp = this->findVPWithBox(box); @@ -581,7 +581,7 @@ VPDrag::updateDraggers () std::vector itemlist=this->selection->itemList(); for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { - SPItem *item = static_cast(*i); + SPItem *item = *i; SPBox3D *box = dynamic_cast(item); if (box) { VanishingPoint vp; @@ -614,7 +614,7 @@ VPDrag::updateLines () std::vector itemlist=this->selection->itemList(); for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { - SPItem *item = static_cast(*i); + SPItem *item = *i; SPBox3D *box = dynamic_cast(item); if (box) { this->drawLinesForFace (box, Proj::X); -- cgit v1.2.3