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/seltrans.cpp | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'src/seltrans.cpp') diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 5e4c0642e..8c06356db 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -112,7 +112,7 @@ Inkscape::SelTrans::SelTrans(SPDesktop *desktop) : _opposite_for_bboxpoints(Geom::Point(0,0)), _origin_for_specpoints(Geom::Point(0,0)), _origin_for_bboxpoints(Geom::Point(0,0)), - _stamp_cache(NULL), + _stamp_cache(SelContainer()), _message_context(desktop->messageStack()), _bounding_box_prefs_observer(*this) { @@ -239,8 +239,9 @@ void Inkscape::SelTrans::setCenter(Geom::Point const &p) _center_is_set = true; // Write the new center position into all selected items - for (GSList const *l = _desktop->selection->itemList(); l; l = l->next) { - SPItem *it = SP_ITEM(l->data); + SelContainer items=_desktop->selection->itemList(); + for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + SPItem *it = SP_ITEM(*iter); it->setCenter(p); // only set the value; updating repr and document_done will be done once, on ungrab } @@ -268,8 +269,9 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s return; } - for (GSList const *l = selection->itemList(); l; l = l->next) { - SPItem *it = reinterpret_cast(sp_object_ref(SP_ITEM(l->data), NULL)); + SelContainer items=_desktop->selection->itemList(); + for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + SPItem *it = reinterpret_cast(sp_object_ref(SP_ITEM(*iter), NULL)); _items.push_back(it); _items_const.push_back(it); _items_affines.push_back(it->i2dt_affine()); @@ -370,7 +372,7 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s } _updateHandles(); - g_return_if_fail(_stamp_cache == NULL); + g_return_if_fail(_stamp_cache.empty()); } void Inkscape::SelTrans::transform(Geom::Affine const &rel_affine, Geom::Point const &norm) @@ -433,9 +435,8 @@ void Inkscape::SelTrans::ungrab() sp_canvas_item_hide(_l[i]); } - if (_stamp_cache) { - g_slist_free(_stamp_cache); - _stamp_cache = NULL; + if (!_stamp_cache.empty()) { + _stamp_cache.clear(); } _message_context.clear(); @@ -491,8 +492,9 @@ void Inkscape::SelTrans::ungrab() if (_center_is_set) { // we were dragging center; update reprs and commit undoable action - for (GSList const *l = _desktop->selection->itemList(); l; l = l->next) { - SPItem *it = SP_ITEM(l->data); + SelContainer items=_desktop->selection->itemList(); + for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + SPItem *it = SP_ITEM(*iter); it->updateRepr(); } DocumentUndo::done(_desktop->getDocument(), SP_VERB_CONTEXT_SELECT, @@ -515,26 +517,25 @@ void Inkscape::SelTrans::stamp() Inkscape::Selection *selection = _desktop->getSelection(); bool fixup = !_grabbed; - if ( fixup && _stamp_cache ) { + if ( fixup && !_stamp_cache.empty() ) { // TODO - give a proper fix. Simple temporary work-around for the grab() issue - g_slist_free(_stamp_cache); - _stamp_cache = NULL; + _stamp_cache.clear(); } /* stamping mode */ if (!_empty) { - GSList *l; - if (_stamp_cache) { + SelContainer l; + if (!_stamp_cache.empty()) { l = _stamp_cache; } else { /* Build cache */ - l = g_slist_copy((GSList *) selection->itemList()); - l = g_slist_sort(l, (GCompareFunc) sp_object_compare_position); + l = selection->itemList(); + l.sort(sp_object_compare_position); _stamp_cache = l; } - while (l) { - SPItem *original_item = SP_ITEM(l->data); + for(SelContainer::const_iterator x=l.begin();x!=l.end();x++) { + SPItem *original_item = SP_ITEM(*x); Inkscape::XML::Node *original_repr = original_item->getRepr(); // remember the position of the item @@ -568,16 +569,14 @@ void Inkscape::SelTrans::stamp() } Inkscape::GC::release(copy_repr); - l = l->next; } DocumentUndo::done(_desktop->getDocument(), SP_VERB_CONTEXT_SELECT, _("Stamp")); } - if ( fixup && _stamp_cache ) { + if ( fixup && !_stamp_cache.empty() ) { // TODO - give a proper fix. Simple temporary work-around for the grab() issue - g_slist_free(_stamp_cache); - _stamp_cache = NULL; + _stamp_cache.clear(); } } @@ -712,8 +711,9 @@ void Inkscape::SelTrans::handleClick(SPKnot */*knot*/, guint state, SPSelTransHa case HANDLE_CENTER: if (state & GDK_SHIFT_MASK) { // Unset the center position for all selected items - for (GSList const *l = _desktop->selection->itemList(); l; l = l->next) { - SPItem *it = SP_ITEM(l->data); + SelContainer items=_desktop->selection->itemList(); + for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + SPItem *it = SP_ITEM(*iter); it->unsetCenter(); it->updateRepr(); _center_is_set = false; // center has changed @@ -1283,7 +1283,7 @@ gboolean Inkscape::SelTrans::centerRequest(Geom::Point &pt, guint state) // items will share a single center. While dragging that single center, it should never snap to the // centers of any of the selected objects. Therefore we will have to pass the list of selected items // to the snapper, to avoid self-snapping of the rotation center - GSList *items = (GSList *) const_cast(_selection)->itemList(); + SelContainer items = const_cast(_selection)->itemList(); SnapManager &m = _desktop->namedview->snap_manager; m.setup(_desktop); m.setRotationCenterSource(items); -- 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/seltrans.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/seltrans.cpp') diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 8c06356db..0a428edf2 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -112,7 +112,7 @@ Inkscape::SelTrans::SelTrans(SPDesktop *desktop) : _opposite_for_bboxpoints(Geom::Point(0,0)), _origin_for_specpoints(Geom::Point(0,0)), _origin_for_bboxpoints(Geom::Point(0,0)), - _stamp_cache(SelContainer()), + _stamp_cache(std::vector()), _message_context(desktop->messageStack()), _bounding_box_prefs_observer(*this) { @@ -239,8 +239,8 @@ void Inkscape::SelTrans::setCenter(Geom::Point const &p) _center_is_set = true; // Write the new center position into all selected items - SelContainer items=_desktop->selection->itemList(); - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + std::vector items=_desktop->selection->itemList(); + for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPItem *it = SP_ITEM(*iter); it->setCenter(p); // only set the value; updating repr and document_done will be done once, on ungrab @@ -269,8 +269,8 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s return; } - SelContainer items=_desktop->selection->itemList(); - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + std::vector items=_desktop->selection->itemList(); + for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPItem *it = reinterpret_cast(sp_object_ref(SP_ITEM(*iter), NULL)); _items.push_back(it); _items_const.push_back(it); @@ -492,8 +492,8 @@ void Inkscape::SelTrans::ungrab() if (_center_is_set) { // we were dragging center; update reprs and commit undoable action - SelContainer items=_desktop->selection->itemList(); - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + std::vector items=_desktop->selection->itemList(); + for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPItem *it = SP_ITEM(*iter); it->updateRepr(); } @@ -524,17 +524,17 @@ void Inkscape::SelTrans::stamp() /* stamping mode */ if (!_empty) { - SelContainer l; + std::vector l; if (!_stamp_cache.empty()) { l = _stamp_cache; } else { /* Build cache */ l = selection->itemList(); - l.sort(sp_object_compare_position); + sort(l.begin(),l.end(),sp_object_compare_position); _stamp_cache = l; } - for(SelContainer::const_iterator x=l.begin();x!=l.end();x++) { + for(std::vector::const_iterator x=l.begin();x!=l.end();x++) { SPItem *original_item = SP_ITEM(*x); Inkscape::XML::Node *original_repr = original_item->getRepr(); @@ -711,8 +711,8 @@ void Inkscape::SelTrans::handleClick(SPKnot */*knot*/, guint state, SPSelTransHa case HANDLE_CENTER: if (state & GDK_SHIFT_MASK) { // Unset the center position for all selected items - SelContainer items=_desktop->selection->itemList(); - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + std::vector items=_desktop->selection->itemList(); + for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPItem *it = SP_ITEM(*iter); it->unsetCenter(); it->updateRepr(); @@ -1283,7 +1283,7 @@ gboolean Inkscape::SelTrans::centerRequest(Geom::Point &pt, guint state) // items will share a single center. While dragging that single center, it should never snap to the // centers of any of the selected objects. Therefore we will have to pass the list of selected items // to the snapper, to avoid self-snapping of the rotation center - SelContainer items = const_cast(_selection)->itemList(); + std::vector items = const_cast(_selection)->itemList(); SnapManager &m = _desktop->namedview->snap_manager; m.setup(_desktop); m.setRotationCenterSource(items); -- 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/seltrans.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/seltrans.cpp') diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 0a428edf2..61d8a1ab1 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -434,8 +434,7 @@ void Inkscape::SelTrans::ungrab() for (int i = 0; i < 4; i++) sp_canvas_item_hide(_l[i]); } - - if (!_stamp_cache.empty()) { + if(!_stamp_cache.empty()){ _stamp_cache.clear(); } @@ -494,7 +493,7 @@ void Inkscape::SelTrans::ungrab() // we were dragging center; update reprs and commit undoable action std::vector items=_desktop->selection->itemList(); for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { - SPItem *it = SP_ITEM(*iter); + SPItem *it = *iter; it->updateRepr(); } DocumentUndo::done(_desktop->getDocument(), SP_VERB_CONTEXT_SELECT, @@ -535,7 +534,7 @@ void Inkscape::SelTrans::stamp() } for(std::vector::const_iterator x=l.begin();x!=l.end();x++) { - SPItem *original_item = SP_ITEM(*x); + SPItem *original_item = *x; Inkscape::XML::Node *original_repr = original_item->getRepr(); // remember the position of the item @@ -713,7 +712,7 @@ void Inkscape::SelTrans::handleClick(SPKnot */*knot*/, guint state, SPSelTransHa // Unset the center position for all selected items std::vector items=_desktop->selection->itemList(); for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { - SPItem *it = SP_ITEM(*iter); + SPItem *it = *iter; it->unsetCenter(); it->updateRepr(); _center_is_set = false; // center has changed -- cgit v1.2.3 From 9bdc157f705ca61516e599cb416580283d21ec35 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Fri, 27 Feb 2015 04:21:48 +0100 Subject: more cast cleanup (bzr r13922.1.11) --- src/seltrans.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/seltrans.cpp') diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 61d8a1ab1..bfb8d53f1 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -271,7 +271,7 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s std::vector items=_desktop->selection->itemList(); for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { - SPItem *it = reinterpret_cast(sp_object_ref(SP_ITEM(*iter), NULL)); + SPItem *it = static_cast(sp_object_ref(*iter, NULL)); _items.push_back(it); _items_const.push_back(it); _items_affines.push_back(it->i2dt_affine()); -- cgit v1.2.3