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/sp-switch.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'src/sp-switch.cpp') diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp index db6db9909..0090f1855 100644 --- a/src/sp-switch.cpp +++ b/src/sp-switch.cpp @@ -55,21 +55,22 @@ SPObject *SPSwitch::_evaluateFirst() { return first; } -GSList *SPSwitch::_childList(bool add_ref, SPObject::Action action) { +SelContainer SPSwitch::_childList(bool add_ref, SPObject::Action action) { if ( action != SPObject::ActionGeneral ) { return this->childList(add_ref, action); } SPObject *child = _evaluateFirst(); + SelContainer x; if (NULL == child) - return NULL; + return x; if (add_ref) { //g_object_ref (G_OBJECT (child)); sp_object_ref(child); } - - return g_slist_prepend (NULL, child); + x.push_front(child); + return x; } const char *SPSwitch::displayName() const { @@ -109,10 +110,9 @@ void SPSwitch::_reevaluate(bool /*add_to_drawing*/) { _releaseLastItem(_cached_item); - for ( GSList *l = _childList(false, SPObject::ActionShow); - NULL != l ; l = g_slist_remove (l, l->data)) - { - SPObject *o = SP_OBJECT (l->data); + SelContainer item_list = _childList(false, SPObject::ActionShow); + for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + SPObject *o = SP_OBJECT (*iter); if ( !SP_IS_ITEM (o) ) { continue; } @@ -144,10 +144,10 @@ void SPSwitch::_releaseLastItem(SPObject *obj) void SPSwitch::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) { SPObject *evaluated_child = this->_evaluateFirst(); - GSList *l = this->_childList(false, SPObject::ActionShow); + SelContainer l = this->_childList(false, SPObject::ActionShow); - while (l) { - SPObject *o = SP_OBJECT (l->data); + for ( SelContainer::const_iterator iter=l.begin();iter!=l.end();iter++) { + SPObject *o = SP_OBJECT (*iter); if (SP_IS_ITEM (o)) { SPItem * child = SP_ITEM(o); @@ -158,8 +158,6 @@ void SPSwitch::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem ai->appendChild(ac); } } - - l = g_slist_remove (l, o); } } -- cgit v1.2.3 From 7e4b6f793d31d3245bd8afbf6f10aa255ac3e7ae Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Thu, 19 Feb 2015 20:20:09 +0100 Subject: added a set to the Selection (bzr r13922.1.6) --- src/sp-switch.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/sp-switch.cpp') diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp index 0090f1855..2c9427df8 100644 --- a/src/sp-switch.cpp +++ b/src/sp-switch.cpp @@ -55,13 +55,13 @@ SPObject *SPSwitch::_evaluateFirst() { return first; } -SelContainer SPSwitch::_childList(bool add_ref, SPObject::Action action) { +std::vector SPSwitch::_childList(bool add_ref, SPObject::Action action) { if ( action != SPObject::ActionGeneral ) { return this->childList(add_ref, action); } SPObject *child = _evaluateFirst(); - SelContainer x; + std::vector x; if (NULL == child) return x; @@ -69,7 +69,7 @@ SelContainer SPSwitch::_childList(bool add_ref, SPObject::Action action) { //g_object_ref (G_OBJECT (child)); sp_object_ref(child); } - x.push_front(child); + x.push_back(child); return x; } @@ -110,8 +110,8 @@ void SPSwitch::_reevaluate(bool /*add_to_drawing*/) { _releaseLastItem(_cached_item); - SelContainer item_list = _childList(false, SPObject::ActionShow); - for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + std::vector item_list = _childList(false, SPObject::ActionShow); + for ( std::vector::const_reverse_iterator iter=item_list.rbegin();iter!=item_list.rend();iter++) { SPObject *o = SP_OBJECT (*iter); if ( !SP_IS_ITEM (o) ) { continue; @@ -144,9 +144,9 @@ void SPSwitch::_releaseLastItem(SPObject *obj) void SPSwitch::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) { SPObject *evaluated_child = this->_evaluateFirst(); - SelContainer l = this->_childList(false, SPObject::ActionShow); + std::vector l = this->_childList(false, SPObject::ActionShow); - for ( SelContainer::const_iterator iter=l.begin();iter!=l.end();iter++) { + for ( std::vector::const_reverse_iterator iter=l.rbegin();iter!=l.rend();iter++) { SPObject *o = SP_OBJECT (*iter); if (SP_IS_ITEM (o)) { -- 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/sp-switch.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/sp-switch.cpp') diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp index 2c9427df8..f252438a4 100644 --- a/src/sp-switch.cpp +++ b/src/sp-switch.cpp @@ -112,7 +112,7 @@ void SPSwitch::_reevaluate(bool /*add_to_drawing*/) { std::vector item_list = _childList(false, SPObject::ActionShow); for ( std::vector::const_reverse_iterator iter=item_list.rbegin();iter!=item_list.rend();iter++) { - SPObject *o = SP_OBJECT (*iter); + SPObject *o = *iter; if ( !SP_IS_ITEM (o) ) { continue; } @@ -147,7 +147,7 @@ void SPSwitch::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem std::vector l = this->_childList(false, SPObject::ActionShow); for ( std::vector::const_reverse_iterator iter=l.rbegin();iter!=l.rend();iter++) { - SPObject *o = SP_OBJECT (*iter); + SPObject *o = *iter; if (SP_IS_ITEM (o)) { SPItem * child = SP_ITEM(o); -- cgit v1.2.3