From 193b25a53c51a36fe9538e03203b0054c8cfc355 Mon Sep 17 00:00:00 2001 From: mc <> Date: Wed, 18 Feb 2015 02:02:37 +0100 Subject: Just... some... more... lines... (bzr r13922.1.2) --- src/ui/tools/connector-tool.cpp | 8 +++----- src/ui/tools/eraser-tool.cpp | 31 +++++++++++++---------------- src/ui/tools/gradient-tool.cpp | 43 ++++++++++++++++++++++++----------------- src/ui/tools/gradient-tool.h | 3 ++- src/ui/tools/lpe-tool.cpp | 8 ++++---- src/ui/tools/measure-tool.cpp | 6 +++--- src/ui/tools/mesh-tool.cpp | 34 +++++++++++++++++++------------- src/ui/tools/node-tool.cpp | 10 ++++------ src/ui/tools/select-tool.cpp | 5 ++--- src/ui/tools/spray-tool.cpp | 32 ++++++++++++------------------ src/ui/tools/text-tool.cpp | 7 +++---- src/ui/tools/tool-base.cpp | 6 ++---- src/ui/tools/tweak-tool.cpp | 25 +++++++++++------------- 13 files changed, 105 insertions(+), 113 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 26a4eadd5..fc40c20e7 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -1313,12 +1313,12 @@ void cc_selection_set_avoid(bool const set_avoid) Inkscape::Selection *selection = desktop->getSelection(); - GSList *l = const_cast(selection->itemList()); int changes = 0; - while (l) { - SPItem *item = SP_ITEM(l->data); + SelContainer l = selection->itemList(); + for(SelContainer::const_iterator i=l.begin();i!=l.end();i++) { + SPItem *item = SP_ITEM(*i); char const *value = (set_avoid) ? "true" : NULL; @@ -1327,8 +1327,6 @@ void cc_selection_set_avoid(bool const set_avoid) item->avoidRef->handleSettingChange(); changes++; } - - l = l->next; } if (changes == 0) { diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 1b4dcfe25..3526e015a 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -676,7 +676,7 @@ void EraserTool::set_to_accumulated() { Geom::OptRect eraserBbox = acid->visualBounds(); Geom::Rect bounds = (*eraserBbox) * desktop->doc2dt(); std::vector remainingItems; - GSList* toWorkOn = 0; + SelContainer toWorkOn; if (selection->isEmpty()) { if ( eraserMode ) { @@ -686,16 +686,16 @@ void EraserTool::set_to_accumulated() { toWorkOn = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints()); } - toWorkOn = g_slist_remove( toWorkOn, acid ); + toWorkOn.remove(static_cast(acid) ); } else { - toWorkOn = g_slist_copy(const_cast(selection->itemList())); + toWorkOn = selection->itemList(); wasSelection = true; } - if ( g_slist_length(toWorkOn) > 0 ) { + if ( !toWorkOn.empty() ) { if ( eraserMode ) { - for (GSList *i = toWorkOn ; i ; i = i->next ) { - SPItem *item = SP_ITEM(i->data); + for (SelContainer::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { + SPItem *item = SP_ITEM(*i); if ( eraserMode ) { Geom::OptRect bbox = item->visualBounds(); @@ -712,13 +712,10 @@ void EraserTool::set_to_accumulated() { if ( !selection->isEmpty() ) { // If the item was not completely erased, track the new remainder. - GSList *nowSel = g_slist_copy(const_cast(selection->itemList())); - - for (GSList const *i2 = nowSel ; i2 ; i2 = i2->next ) { - remainingItems.push_back(SP_ITEM(i2->data)); + SelContainer nowSel(selection->itemList()); + for (SelContainer::const_iterator i2 = nowSel.begin();i!=nowSel.end();i++) { + remainingItems.push_back(SP_ITEM(*i2)); } - - g_slist_free(nowSel); } } else { remainingItems.push_back(item); @@ -726,20 +723,18 @@ void EraserTool::set_to_accumulated() { } } } else { - for (GSList *i = toWorkOn ; i ; i = i->next ) { - sp_object_ref( SP_ITEM(i->data), 0 ); + for (SelContainer::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { + sp_object_ref( SP_ITEM(*i), 0 ); } - for (GSList *i = toWorkOn ; i ; i = i->next ) { - SPItem *item = SP_ITEM(i->data); + for (SelContainer::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { + SPItem *item = SP_ITEM(*i); item->deleteObject(true); sp_object_unref(item); workDone = true; } } - g_slist_free(toWorkOn); - if ( !eraserMode ) { //sp_selection_delete(desktop); remainingItems.clear(); diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 5da30da7b..d1db5fb93 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -116,7 +116,7 @@ void GradientTool::selection_changed(Inkscape::Selection*) { if (selection == NULL) { return; } - guint n_obj = g_slist_length((GSList *) selection->itemList()); + guint n_obj = selection->itemList().size(); if (!drag->isNonEmpty() || selection->isEmpty()) return; @@ -502,10 +502,11 @@ bool GradientTool::root_handler(GdkEvent* event) { if (over_line) { // we take the first item in selection, because with doubleclick, the first click // always resets selection to the single object under cursor - sp_gradient_context_add_stop_near_point(this, SP_ITEM(selection->itemList()->data), this->mousepoint_doc, event->button.time); + sp_gradient_context_add_stop_near_point(this, SP_ITEM(selection->itemList().front()), this->mousepoint_doc, event->button.time); } else { - for (GSList const* i = selection->itemList(); i != NULL; i = i->next) { - SPItem *item = SP_ITEM(i->data); + SelContainer items=selection->itemList(); + for (SelContainer::const_iterator i = items.begin();i!=items.end();i++) { + SPItem *item = SP_ITEM(*i); SPGradientType new_type = (SPGradientType) prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR); Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE; @@ -889,6 +890,12 @@ bool GradientTool::root_handler(GdkEvent* event) { return ret; } +int sp_item_repr_compare_position_obj(SPObject const *first, SPObject const *second) +{ + return sp_repr_compare_position(((SPItem*)first)->getRepr(), + ((SPItem*)second)->getRepr())<0; +} + static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*state*/, guint32 etime) { SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop; @@ -908,32 +915,32 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta } else { // Starting from empty space: // Sort items so that the topmost comes last - GSList *items = g_slist_copy ((GSList *) selection->itemList()); - items = g_slist_sort(items, (GCompareFunc) sp_item_repr_compare_position); + SelContainer items(selection->itemList()); + items.sort(sp_item_repr_compare_position_obj); // take topmost - vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(g_slist_last(items)->data), fill_or_stroke); - g_slist_free (items); + vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke); } // HACK: reset fill-opacity - that 0.75 is annoying; BUT remove this when we have an opacity slider for all tabs SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_set_property(css, "fill-opacity", "1.0"); - for (GSList const *i = selection->itemList(); i != NULL; i = i->next) { + SelContainer itemlist = selection->itemList(); + for (SelContainer::const_iterator i = itemlist.begin();i!=itemlist.end();i++) { //FIXME: see above - sp_repr_css_change_recursive(SP_OBJECT(i->data)->getRepr(), css, "style"); + sp_repr_css_change_recursive(SP_OBJECT(*i)->getRepr(), css, "style"); - sp_item_set_gradient(SP_ITEM(i->data), vector, (SPGradientType) type, fill_or_stroke); + sp_item_set_gradient(SP_ITEM(*i), vector, (SPGradientType) type, fill_or_stroke); if (type == SP_GRADIENT_TYPE_LINEAR) { - sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_LG_BEGIN, 0, rc.origin, fill_or_stroke, true, false); - sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_LG_END, 0, pt, fill_or_stroke, true, false); + sp_item_gradient_set_coords (SP_ITEM(*i), POINT_LG_BEGIN, 0, rc.origin, fill_or_stroke, true, false); + sp_item_gradient_set_coords (SP_ITEM(*i), POINT_LG_END, 0, pt, fill_or_stroke, true, false); } else if (type == SP_GRADIENT_TYPE_RADIAL) { - sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_RG_CENTER, 0, rc.origin, fill_or_stroke, true, false); - sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_RG_R1, 0, pt, fill_or_stroke, true, false); + sp_item_gradient_set_coords (SP_ITEM(*i), POINT_RG_CENTER, 0, rc.origin, fill_or_stroke, true, false); + sp_item_gradient_set_coords (SP_ITEM(*i), POINT_RG_R1, 0, pt, fill_or_stroke, true, false); } - SP_OBJECT(i->data)->requestModified(SP_OBJECT_MODIFIED_FLAG); + SP_OBJECT(*i)->requestModified(SP_OBJECT_MODIFIED_FLAG); } if (ec->_grdrag) { ec->_grdrag->updateDraggers(); @@ -942,7 +949,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta ec->_grdrag->local_change = true; // give the grab out-of-bounds values of xp/yp because we're already dragging // and therefore are already out of tolerance - ec->_grdrag->grabKnot (SP_ITEM(selection->itemList()->data), + ec->_grdrag->grabKnot (SP_ITEM(selection->itemList().front()), type == SP_GRADIENT_TYPE_LINEAR? POINT_LG_END : POINT_RG_R1, -1, // ignore number (though it is always 1) fill_or_stroke, 99999, 99999, etime); @@ -951,7 +958,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta // status text; we do not track coords because this branch is run once, not all the time // during drag - int n_objects = g_slist_length((GSList *) selection->itemList()); + int n_objects = selection->itemList().size(); rc.message_context->setF(Inkscape::NORMAL_MESSAGE, ngettext("Gradient for %d object; with Ctrl to snap angle", "Gradient for %d objects; with Ctrl to snap angle", n_objects), diff --git a/src/ui/tools/gradient-tool.h b/src/ui/tools/gradient-tool.h index 6fe3bca9f..786aed372 100644 --- a/src/ui/tools/gradient-tool.h +++ b/src/ui/tools/gradient-tool.h @@ -18,6 +18,7 @@ #include #include #include "ui/tools/tool-base.h" +class SPObject;//kill it #define SP_GRADIENT_CONTEXT(obj) (dynamic_cast((Inkscape::UI::Tools::ToolBase*)obj)) #define SP_IS_GRADIENT_CONTEXT(obj) (dynamic_cast((const Inkscape::UI::Tools::ToolBase*)obj) != NULL) @@ -25,12 +26,12 @@ namespace Inkscape { namespace UI { namespace Tools { +int sp_item_repr_compare_position_obj(SPObject const *first, SPObject const *second);//kill it class GradientTool : public ToolBase { public: GradientTool(); virtual ~GradientTool(); - Geom::Point origin; bool cursor_addnode; diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp index c9b656397..ce0ad7a9a 100644 --- a/src/ui/tools/lpe-tool.cpp +++ b/src/ui/tools/lpe-tool.cpp @@ -407,10 +407,10 @@ lpetool_create_measuring_items(LpeTool *lc, Inkscape::Selection *selection) SPCanvasGroup *tmpgrp = lc->desktop->getTempGroup(); gchar *arc_length; double lengthval; - - for (GSList const *i = selection->itemList(); i != NULL; i = i->next) { - if (SP_IS_PATH(i->data)) { - path = SP_PATH(i->data); + SelContainer items=selection->itemList(); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + if (SP_IS_PATH(*i)) { + path = SP_PATH(*i); curve = path->getCurve(); Geom::Piecewise > pwd2 = paths_to_pw(curve->get_pathvector()); canvas_text = (SPCanvasText *) sp_canvastext_new(tmpgrp, lc->desktop, Geom::Point(0,0), ""); diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index b7e54b9c8..8d52210ff 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -441,10 +441,10 @@ bool MeasureTool::root_handler(GdkEvent* event) { // TODO switch to a different variable name. The single letter 'l' is easy to misread. //select elements crossed by line segment: - GSList *items = desktop->getDocument()->getItemsAtPoints(desktop->dkey, points); + SelContainer items = desktop->getDocument()->getItemsAtPoints(desktop->dkey, points); std::vector intersection_times; - for (GSList *l = items; l != NULL; l = l->next) { - SPItem *item = static_cast(l->data); + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + SPItem *item = static_cast(*i); if (SP_IS_SHAPE(item)) { calculate_intersections(desktop, item, lineseg, SP_SHAPE(item)->getCurve(), intersection_times); diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index d333b932e..1cc06a5b9 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -48,6 +48,7 @@ // Mesh specific #include "ui/tools/mesh-tool.h" +#include "ui/tools/gradient-tool.h"//not needed #include "sp-mesh-gradient.h" #include "display/sp-ctrlcurve.h" @@ -113,7 +114,7 @@ void MeshTool::selection_changed(Inkscape::Selection* /*sel*/) { return; } - guint n_obj = g_slist_length((GSList *) selection->itemList()); + guint n_obj = selection->itemList().size(); if (!drag->isNonEmpty() || selection->isEmpty()) { return; @@ -477,11 +478,12 @@ bool MeshTool::root_handler(GdkEvent* event) { if (over_line) { // We take the first item in selection, because with doubleclick, the first click // always resets selection to the single object under cursor - sp_mesh_context_split_near_point(this, SP_ITEM(selection->itemList()->data), this->mousepoint_doc, event->button.time); + sp_mesh_context_split_near_point(this, SP_ITEM(selection->itemList().front()), this->mousepoint_doc, event->button.time); } else { // Create a new gradient with default coordinates. - for (GSList const* i = selection->itemList(); i != NULL; i = i->next) { - SPItem *item = SP_ITEM(i->data); + SelContainer items=selection->itemList(); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + SPItem *item = SP_ITEM(*i); SPGradientType new_type = SP_GRADIENT_TYPE_MESH; Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE; @@ -930,6 +932,12 @@ bool MeshTool::root_handler(GdkEvent* event) { return ret; } +/* +int sp_item_repr_compare_position_obj(SPObject const *first, SPObject const *second) +{ + return sp_repr_compare_position(((SPItem*)first)->getRepr(), + ((SPItem*)second)->getRepr())<0; +}*/ static void sp_mesh_drag(MeshTool &rc, Geom::Point const /*pt*/, guint /*state*/, guint32 /*etime*/) { SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop; @@ -950,27 +958,27 @@ static void sp_mesh_drag(MeshTool &rc, Geom::Point const /*pt*/, guint /*state*/ } else { // Starting from empty space: // Sort items so that the topmost comes last - GSList *items = g_slist_copy ((GSList *) selection->itemList()); - items = g_slist_sort(items, (GCompareFunc) sp_item_repr_compare_position); + SelContainer items(selection->itemList()); + items.sort(sp_item_repr_compare_position_obj); // take topmost - vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(g_slist_last(items)->data), fill_or_stroke); - g_slist_free (items); + vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke); } // HACK: reset fill-opacity - that 0.75 is annoying; BUT remove this when we have an opacity slider for all tabs SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_set_property(css, "fill-opacity", "1.0"); - for (GSList const *i = selection->itemList(); i != NULL; i = i->next) { + SelContainer items=selection->itemList(); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ //FIXME: see above - sp_repr_css_change_recursive(SP_OBJECT(i->data)->getRepr(), css, "style"); + sp_repr_css_change_recursive(SP_OBJECT(*i)->getRepr(), css, "style"); - sp_item_set_gradient(SP_ITEM(i->data), vector, (SPGradientType) type, fill_or_stroke); + sp_item_set_gradient(SP_ITEM(*i), vector, (SPGradientType) type, fill_or_stroke); // We don't need to do anything. Mesh is already sized appropriately. - SP_OBJECT(i->data)->requestModified(SP_OBJECT_MODIFIED_FLAG); + SP_OBJECT(*i)->requestModified(SP_OBJECT_MODIFIED_FLAG); } // if (ec->_grdrag) { // ec->_grdrag->updateDraggers(); @@ -988,7 +996,7 @@ static void sp_mesh_drag(MeshTool &rc, Geom::Point const /*pt*/, guint /*state*/ // status text; we do not track coords because this branch is run once, not all the time // during drag - int n_objects = g_slist_length((GSList *) selection->itemList()); + int n_objects = selection->itemList().size(); rc.message_context->setF(Inkscape::NORMAL_MESSAGE, ngettext("Gradient for %d object; with Ctrl to snap angle", "Gradient for %d objects; with Ctrl to snap angle", n_objects), diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index caec901a6..46c978c84 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -420,10 +420,9 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) { std::set shapes; - GSList const *ilist = sel->itemList(); - - for (GSList *i = const_cast(ilist); i; i = i->next) { - SPObject *obj = static_cast(i->data); + SelContainer items=sel->itemList(); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + SPObject *obj = static_cast(*i); if (SP_IS_ITEM(obj)) { gather_items(this, NULL, static_cast(obj), SHAPE_ROLE_NORMAL, shapes); @@ -668,9 +667,8 @@ void NodeTool::select_area(Geom::Rect const &sel, GdkEventButton *event) { if (this->_multipath->empty()) { // if multipath is empty, select rubberbanded items rather than nodes Inkscape::Selection *selection = this->desktop->selection; - GSList *items = this->desktop->getDocument()->getItemsInBox(this->desktop->dkey, sel); + SelContainer items = this->desktop->getDocument()->getItemsInBox(this->desktop->dkey, sel); selection->setList(items); - g_slist_free(items); } else { if (!held_shift(*event)) { this->_selected_nodes->clear(); diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index 939b1a0b3..f84170631 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -481,7 +481,7 @@ bool SelectTool::root_handler(GdkEvent* event) { case GDK_2BUTTON_PRESS: if (event->button.button == 1) { if (!selection->isEmpty()) { - SPItem *clicked_item = static_cast(selection->itemList()->data); + SPItem *clicked_item = static_cast(selection->itemList().front()); if (dynamic_cast(clicked_item) && !dynamic_cast(clicked_item)) { // enter group if it's not a 3D box desktop->setCurrentLayer(clicked_item); @@ -718,7 +718,7 @@ bool SelectTool::root_handler(GdkEvent* event) { if (r->is_started() && !within_tolerance) { // this was a rubberband drag - GSList *items = NULL; + SelContainer items; if (r->getMode() == RUBBERBAND_MODE_RECT) { Geom::OptRect const b = r->getRectangle(); @@ -739,7 +739,6 @@ bool SelectTool::root_handler(GdkEvent* event) { selection->setList (items); } - g_slist_free (items); } else { // it was just a click, or a too small rubberband r->stop(); diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index a01c5c55b..d339f6d19 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -188,7 +188,7 @@ void SprayTool::update_cursor(bool /*with_shift*/) { gchar *sel_message = NULL; if (!desktop->selection->isEmpty()) { - num = g_slist_length(const_cast(desktop->selection->itemList())); + num = desktop->selection->itemList().size(); sel_message = g_strdup_printf(ngettext("%i object selected","%i objects selected",num), num); } else { sel_message = g_strdup_printf("%s", _("Nothing selected")); @@ -436,11 +436,9 @@ static bool sp_spray_recursive(SPDesktop *desktop, SPItem *unionResult = NULL; // Previous union int i=1; - for (GSList *items = g_slist_copy(const_cast(selection->itemList())); - items != NULL; - items = items->next) { - - SPItem *item1 = dynamic_cast(static_cast(items->data)); + SelContainer items=selection->itemList(); + for(SelContainer::const_iterator it=items.begin();it!=items.end();it++){ + SPItem *item1 = dynamic_cast(static_cast(*it)); if (i == 1) { parent_item = item1; } @@ -552,20 +550,16 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point double move_standard_deviation = get_move_standard_deviation(tc); { - GSList *const original_selection = g_slist_copy(const_cast(selection->itemList())); + SelContainer const items(selection->itemList()); - for (GSList *items = original_selection; - items != NULL; - items = items->next) { - SPItem *item = dynamic_cast(static_cast(items->data)); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + SPItem *item = dynamic_cast(static_cast(*i)); g_assert(item != NULL); sp_object_ref(item); } - for (GSList *items = original_selection; - items != NULL; - items = items->next) { - SPItem *item = dynamic_cast(static_cast(items->data)); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + SPItem *item = dynamic_cast(static_cast(*i)); g_assert(item != NULL); if (is_transform_modes(tc->mode)) { @@ -579,10 +573,8 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point } } - for (GSList *items = original_selection; - items != NULL; - items = items->next) { - SPItem *item = dynamic_cast(static_cast(items->data)); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + SPItem *item = dynamic_cast(static_cast(*i)); g_assert(item != NULL); sp_object_unref(item); } @@ -658,7 +650,7 @@ bool SprayTool::root_handler(GdkEvent* event) { guint num = 0; if (!desktop->selection->isEmpty()) { - num = g_slist_length(const_cast(desktop->selection->itemList())); + num = desktop->selection->itemList().size(); } if (num == 0) { this->message_context->flash(Inkscape::ERROR_MESSAGE, _("Nothing selected! Select objects to spray.")); diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index df0583d67..a4370256d 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -1470,7 +1470,7 @@ int TextTool::_styleQueried(SPStyle *style, int property) } sp_text_context_validate_cursor_iterators(this); - GSList *styles_list = NULL; + SelContainer styles_list; Inkscape::Text::Layout::iterator begin_it, end_it; if (this->text_sel_start < this->text_sel_end) { @@ -1486,7 +1486,7 @@ int TextTool::_styleQueried(SPStyle *style, int property) } } for (Inkscape::Text::Layout::iterator it = begin_it ; it < end_it ; it.nextStartOfSpan()) { - SPObject const *pos_obj = 0; + SPObject *pos_obj = 0; void *rawptr = 0; layout->getSourceOfCharacter(it, &rawptr); if (!rawptr || !SP_IS_OBJECT(rawptr)) { @@ -1496,12 +1496,11 @@ int TextTool::_styleQueried(SPStyle *style, int property) while (SP_IS_STRING(pos_obj) && pos_obj->parent) { pos_obj = pos_obj->parent; // SPStrings don't have style } - styles_list = g_slist_prepend(styles_list, (gpointer)pos_obj); + styles_list.push_front(pos_obj); } int result = sp_desktop_query_style_from_list (styles_list, style, property); - g_slist_free(styles_list); return result; } diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index a07f2fb86..cc05f9775 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -1178,11 +1178,9 @@ SPItem *sp_event_context_find_item(SPDesktop *desktop, Geom::Point const &p, SPItem * sp_event_context_over_item(SPDesktop *desktop, SPItem *item, Geom::Point const &p) { - GSList *temp = NULL; - temp = g_slist_prepend(temp, item); + SelContainer temp; + temp.push_front(static_cast(item)); SPItem *item_at_point = desktop->getItemFromListAtPointBottom(temp, p); - g_slist_free(temp); - return item_at_point; } diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 5e53fdb93..9342127ce 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -163,7 +163,7 @@ void TweakTool::update_cursor (bool with_shift) { gchar *sel_message = NULL; if (!desktop->selection->isEmpty()) { - num = g_slist_length(const_cast(desktop->selection->itemList())); + num = desktop->selection->itemList().size(); sel_message = g_strdup_printf(ngettext("%i object selected","%i objects selected",num), num); } else { sel_message = g_strdup_printf("%s", _("Nothing selected")); @@ -382,14 +382,13 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P } if (dynamic_cast(item) || dynamic_cast(item)) { - GSList *items = g_slist_prepend (NULL, item); - GSList *selected = NULL; - GSList *to_select = NULL; + SelContainer items; + items.push_back(item); + SelContainer selected; + SelContainer to_select; SPDocument *doc = item->document; - sp_item_list_to_curves (items, &selected, &to_select); - g_slist_free (items); - SPObject* newObj = doc->getObjectByRepr(static_cast(to_select->data)); - g_slist_free (to_select); + sp_item_list_to_curves (items, selected, to_select); + SPObject* newObj = doc->getObjectByRepr(dynamic_cast(to_select.front())); item = dynamic_cast(newObj); g_assert(item != NULL); selection->add(item); @@ -1088,11 +1087,9 @@ sp_tweak_dilate (TweakTool *tc, Geom::Point event_p, Geom::Point p, Geom::Point double move_force = get_move_force(tc); double color_force = MIN(sqrt(path_force)/20.0, 1); - for (GSList *items = g_slist_copy(const_cast(selection->itemList())); - items != NULL; - items = items->next) { - - SPItem *item = dynamic_cast(static_cast(items->data)); + SelContainer items=selection->itemList(); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + SPItem *item = dynamic_cast(static_cast(*i)); if (is_color_mode (tc->mode)) { if (do_fill || do_stroke || do_opacity) { @@ -1199,7 +1196,7 @@ bool TweakTool::root_handler(GdkEvent* event) { guint num = 0; if (!desktop->selection->isEmpty()) { - num = g_slist_length(const_cast(desktop->selection->itemList())); + num = desktop->selection->itemList().size(); } if (num == 0) { this->message_context->flash(Inkscape::ERROR_MESSAGE, _("Nothing selected! Select objects to tweak.")); -- 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/ui/tools/connector-tool.cpp | 4 ++-- src/ui/tools/eraser-tool.cpp | 18 ++++++++---------- src/ui/tools/gradient-tool.cpp | 12 ++++++------ src/ui/tools/lpe-tool.cpp | 4 ++-- src/ui/tools/measure-tool.cpp | 4 ++-- src/ui/tools/mesh-tool.cpp | 12 ++++++------ src/ui/tools/node-tool.cpp | 6 +++--- src/ui/tools/select-tool.cpp | 2 +- src/ui/tools/spray-tool.cpp | 14 +++++++------- src/ui/tools/text-tool.cpp | 4 ++-- src/ui/tools/tool-base.cpp | 4 ++-- src/ui/tools/tweak-tool.cpp | 12 ++++++------ 12 files changed, 47 insertions(+), 49 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index fc40c20e7..9c6eead16 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -1316,8 +1316,8 @@ void cc_selection_set_avoid(bool const set_avoid) int changes = 0; - SelContainer l = selection->itemList(); - for(SelContainer::const_iterator i=l.begin();i!=l.end();i++) { + std::vector l = selection->itemList(); + for(std::vector::const_iterator i=l.begin();i!=l.end();i++) { SPItem *item = SP_ITEM(*i); char const *value = (set_avoid) ? "true" : NULL; diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 3526e015a..520b93e72 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -676,8 +676,7 @@ void EraserTool::set_to_accumulated() { Geom::OptRect eraserBbox = acid->visualBounds(); Geom::Rect bounds = (*eraserBbox) * desktop->doc2dt(); std::vector remainingItems; - SelContainer toWorkOn; - + std::vector toWorkOn; if (selection->isEmpty()) { if ( eraserMode ) { toWorkOn = desktop->getDocument()->getItemsPartiallyInBox(desktop->dkey, bounds); @@ -685,16 +684,15 @@ void EraserTool::set_to_accumulated() { Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); toWorkOn = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints()); } - - toWorkOn.remove(static_cast(acid) ); + toWorkOn.erase(find(toWorkOn.begin(),toWorkOn.end(),acid)); } else { - toWorkOn = selection->itemList(); + toWorkOn= selection->itemList(); wasSelection = true; } if ( !toWorkOn.empty() ) { if ( eraserMode ) { - for (SelContainer::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { + for (std::vector::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { SPItem *item = SP_ITEM(*i); if ( eraserMode ) { @@ -712,8 +710,8 @@ void EraserTool::set_to_accumulated() { if ( !selection->isEmpty() ) { // If the item was not completely erased, track the new remainder. - SelContainer nowSel(selection->itemList()); - for (SelContainer::const_iterator i2 = nowSel.begin();i!=nowSel.end();i++) { + std::vector nowSel(selection->itemList()); + for (std::vector::const_iterator i2 = nowSel.begin();i!=nowSel.end();i2++) { remainingItems.push_back(SP_ITEM(*i2)); } } @@ -723,11 +721,11 @@ void EraserTool::set_to_accumulated() { } } } else { - for (SelContainer::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { + for (std::vector ::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { sp_object_ref( SP_ITEM(*i), 0 ); } - for (SelContainer::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { + for (std::vector::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { SPItem *item = SP_ITEM(*i); item->deleteObject(true); sp_object_unref(item); diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index d1db5fb93..6f7b220ed 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -504,8 +504,8 @@ bool GradientTool::root_handler(GdkEvent* event) { // always resets selection to the single object under cursor sp_gradient_context_add_stop_near_point(this, SP_ITEM(selection->itemList().front()), this->mousepoint_doc, event->button.time); } else { - SelContainer items=selection->itemList(); - for (SelContainer::const_iterator i = items.begin();i!=items.end();i++) { + std::vector items=selection->itemList(); + for (std::vector::const_iterator i = items.begin();i!=items.end();i++) { SPItem *item = SP_ITEM(*i); SPGradientType new_type = (SPGradientType) prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR); Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE; @@ -915,8 +915,8 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta } else { // Starting from empty space: // Sort items so that the topmost comes last - SelContainer items(selection->itemList()); - items.sort(sp_item_repr_compare_position_obj); + std::vector items(selection->itemList()); + sort(items.begin(),items.end(),sp_item_repr_compare_position); // take topmost vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke); } @@ -925,8 +925,8 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_set_property(css, "fill-opacity", "1.0"); - SelContainer itemlist = selection->itemList(); - for (SelContainer::const_iterator i = itemlist.begin();i!=itemlist.end();i++) { + std::vector itemlist = selection->itemList(); + for (std::vector::const_iterator i = itemlist.begin();i!=itemlist.end();i++) { //FIXME: see above sp_repr_css_change_recursive(SP_OBJECT(*i)->getRepr(), css, "style"); diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp index ce0ad7a9a..290eeef87 100644 --- a/src/ui/tools/lpe-tool.cpp +++ b/src/ui/tools/lpe-tool.cpp @@ -407,8 +407,8 @@ lpetool_create_measuring_items(LpeTool *lc, Inkscape::Selection *selection) SPCanvasGroup *tmpgrp = lc->desktop->getTempGroup(); gchar *arc_length; double lengthval; - SelContainer items=selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector items=selection->itemList(); + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ if (SP_IS_PATH(*i)) { path = SP_PATH(*i); curve = path->getCurve(); diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index 8d52210ff..2b44639c8 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -441,9 +441,9 @@ bool MeasureTool::root_handler(GdkEvent* event) { // TODO switch to a different variable name. The single letter 'l' is easy to misread. //select elements crossed by line segment: - SelContainer items = desktop->getDocument()->getItemsAtPoints(desktop->dkey, points); + std::vector items = desktop->getDocument()->getItemsAtPoints(desktop->dkey, points); std::vector intersection_times; - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + for (std::vector::const_iterator i=items.begin();i!=items.end();i++) { SPItem *item = static_cast(*i); if (SP_IS_SHAPE(item)) { diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 1cc06a5b9..0a34e4855 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -481,8 +481,8 @@ bool MeshTool::root_handler(GdkEvent* event) { sp_mesh_context_split_near_point(this, SP_ITEM(selection->itemList().front()), this->mousepoint_doc, event->button.time); } else { // Create a new gradient with default coordinates. - SelContainer items=selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector items=selection->itemList(); + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = SP_ITEM(*i); SPGradientType new_type = SP_GRADIENT_TYPE_MESH; Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE; @@ -958,8 +958,8 @@ static void sp_mesh_drag(MeshTool &rc, Geom::Point const /*pt*/, guint /*state*/ } else { // Starting from empty space: // Sort items so that the topmost comes last - SelContainer items(selection->itemList()); - items.sort(sp_item_repr_compare_position_obj); + std::vector items(selection->itemList()); + sort(items.begin(),items.end(),sp_item_repr_compare_position); // take topmost vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke); } @@ -968,8 +968,8 @@ static void sp_mesh_drag(MeshTool &rc, Geom::Point const /*pt*/, guint /*state*/ SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_set_property(css, "fill-opacity", "1.0"); - SelContainer items=selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector items=selection->itemList(); + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ //FIXME: see above sp_repr_css_change_recursive(SP_OBJECT(*i)->getRepr(), css, "style"); diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 46c978c84..6ddb379cc 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -420,8 +420,8 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) { std::set shapes; - SelContainer items=sel->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector items=sel->itemList(); + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ SPObject *obj = static_cast(*i); if (SP_IS_ITEM(obj)) { @@ -667,7 +667,7 @@ void NodeTool::select_area(Geom::Rect const &sel, GdkEventButton *event) { if (this->_multipath->empty()) { // if multipath is empty, select rubberbanded items rather than nodes Inkscape::Selection *selection = this->desktop->selection; - SelContainer items = this->desktop->getDocument()->getItemsInBox(this->desktop->dkey, sel); + std::vector items = this->desktop->getDocument()->getItemsInBox(this->desktop->dkey, sel); selection->setList(items); } else { if (!held_shift(*event)) { diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index f84170631..25cbf76a4 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -718,7 +718,7 @@ bool SelectTool::root_handler(GdkEvent* event) { if (r->is_started() && !within_tolerance) { // this was a rubberband drag - SelContainer items; + std::vector items; if (r->getMode() == RUBBERBAND_MODE_RECT) { Geom::OptRect const b = r->getRectangle(); diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index d339f6d19..ac41f3a34 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -436,9 +436,9 @@ static bool sp_spray_recursive(SPDesktop *desktop, SPItem *unionResult = NULL; // Previous union int i=1; - SelContainer items=selection->itemList(); - for(SelContainer::const_iterator it=items.begin();it!=items.end();it++){ - SPItem *item1 = dynamic_cast(static_cast(*it)); + std::vector items=selection->itemList(); + for(std::vector::const_iterator it=items.begin();it!=items.end();it++){ + SPItem *item1 = *it; if (i == 1) { parent_item = item1; } @@ -550,15 +550,15 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point double move_standard_deviation = get_move_standard_deviation(tc); { - SelContainer const items(selection->itemList()); + std::vector const items(selection->itemList()); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = dynamic_cast(static_cast(*i)); g_assert(item != NULL); sp_object_ref(item); } - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = dynamic_cast(static_cast(*i)); g_assert(item != NULL); @@ -573,7 +573,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point } } - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = dynamic_cast(static_cast(*i)); g_assert(item != NULL); sp_object_unref(item); diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index a4370256d..48c109688 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -1470,7 +1470,7 @@ int TextTool::_styleQueried(SPStyle *style, int property) } sp_text_context_validate_cursor_iterators(this); - SelContainer styles_list; + std::vector styles_list; Inkscape::Text::Layout::iterator begin_it, end_it; if (this->text_sel_start < this->text_sel_end) { @@ -1496,7 +1496,7 @@ int TextTool::_styleQueried(SPStyle *style, int property) while (SP_IS_STRING(pos_obj) && pos_obj->parent) { pos_obj = pos_obj->parent; // SPStrings don't have style } - styles_list.push_front(pos_obj); + styles_list.insert(styles_list.begin(),(SPItem*)pos_obj); } int result = sp_desktop_query_style_from_list (styles_list, style, property); diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index cc05f9775..def8080d0 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -1178,8 +1178,8 @@ SPItem *sp_event_context_find_item(SPDesktop *desktop, Geom::Point const &p, SPItem * sp_event_context_over_item(SPDesktop *desktop, SPItem *item, Geom::Point const &p) { - SelContainer temp; - temp.push_front(static_cast(item)); + std::vector temp; + temp.push_back(item); SPItem *item_at_point = desktop->getItemFromListAtPointBottom(temp, p); return item_at_point; } diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 9342127ce..6f7764506 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -382,13 +382,13 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P } if (dynamic_cast(item) || dynamic_cast(item)) { - SelContainer items; + std::vector items; items.push_back(item); - SelContainer selected; - SelContainer to_select; + std::vector selected; + std::vector to_select; SPDocument *doc = item->document; sp_item_list_to_curves (items, selected, to_select); - SPObject* newObj = doc->getObjectByRepr(dynamic_cast(to_select.front())); + SPObject* newObj = doc->getObjectByRepr(to_select.back()); item = dynamic_cast(newObj); g_assert(item != NULL); selection->add(item); @@ -1087,8 +1087,8 @@ sp_tweak_dilate (TweakTool *tc, Geom::Point event_p, Geom::Point p, Geom::Point double move_force = get_move_force(tc); double color_force = MIN(sqrt(path_force)/20.0, 1); - SelContainer items=selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector items=selection->itemList(); + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = dynamic_cast(static_cast(*i)); if (is_color_mode (tc->mode)) { -- 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/ui/tools/eraser-tool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 520b93e72..b61a108f0 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -711,7 +711,7 @@ void EraserTool::set_to_accumulated() { if ( !selection->isEmpty() ) { // If the item was not completely erased, track the new remainder. std::vector nowSel(selection->itemList()); - for (std::vector::const_iterator i2 = nowSel.begin();i!=nowSel.end();i2++) { + for (std::vector::const_iterator i2 = nowSel.begin();i2!=nowSel.end();i2++) { remainingItems.push_back(SP_ITEM(*i2)); } } -- 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/ui/tools/connector-tool.cpp | 2 +- src/ui/tools/eraser-tool.cpp | 10 +++++----- src/ui/tools/gradient-tool.cpp | 20 +++++++------------- src/ui/tools/gradient-tool.h | 3 +-- src/ui/tools/measure-tool.cpp | 2 +- src/ui/tools/mesh-tool.cpp | 11 ++--------- src/ui/tools/select-tool.cpp | 2 +- src/ui/tools/spray-tool.cpp | 6 +++--- src/ui/tools/tweak-tool.cpp | 2 +- 9 files changed, 22 insertions(+), 36 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 9c6eead16..f48e572df 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -1318,7 +1318,7 @@ void cc_selection_set_avoid(bool const set_avoid) std::vector l = selection->itemList(); for(std::vector::const_iterator i=l.begin();i!=l.end();i++) { - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; char const *value = (set_avoid) ? "true" : NULL; diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index b61a108f0..adbbb2bd3 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -692,8 +692,8 @@ void EraserTool::set_to_accumulated() { if ( !toWorkOn.empty() ) { if ( eraserMode ) { - for (std::vector::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { - SPItem *item = SP_ITEM(*i); + for (std::vector::const_iterator i = toWorkOn.begin(); i != toWorkOn.end(); i++){ + SPItem *item = *i; if ( eraserMode ) { Geom::OptRect bbox = item->visualBounds(); @@ -712,7 +712,7 @@ void EraserTool::set_to_accumulated() { // If the item was not completely erased, track the new remainder. std::vector nowSel(selection->itemList()); for (std::vector::const_iterator i2 = nowSel.begin();i2!=nowSel.end();i2++) { - remainingItems.push_back(SP_ITEM(*i2)); + remainingItems.push_back(*i2); } } } else { @@ -722,11 +722,11 @@ void EraserTool::set_to_accumulated() { } } else { for (std::vector ::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { - sp_object_ref( SP_ITEM(*i), 0 ); + sp_object_ref( *i, 0 ); } for (std::vector::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; item->deleteObject(true); sp_object_unref(item); workDone = true; diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 6f7b220ed..21ad18c26 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -506,7 +506,7 @@ bool GradientTool::root_handler(GdkEvent* event) { } else { std::vector items=selection->itemList(); for (std::vector::const_iterator i = items.begin();i!=items.end();i++) { - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; SPGradientType new_type = (SPGradientType) prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR); Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE; @@ -890,12 +890,6 @@ bool GradientTool::root_handler(GdkEvent* event) { return ret; } -int sp_item_repr_compare_position_obj(SPObject const *first, SPObject const *second) -{ - return sp_repr_compare_position(((SPItem*)first)->getRepr(), - ((SPItem*)second)->getRepr())<0; -} - static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*state*/, guint32 etime) { SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop; @@ -931,14 +925,14 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta //FIXME: see above sp_repr_css_change_recursive(SP_OBJECT(*i)->getRepr(), css, "style"); - sp_item_set_gradient(SP_ITEM(*i), vector, (SPGradientType) type, fill_or_stroke); + sp_item_set_gradient(*i, vector, (SPGradientType) type, fill_or_stroke); if (type == SP_GRADIENT_TYPE_LINEAR) { - sp_item_gradient_set_coords (SP_ITEM(*i), POINT_LG_BEGIN, 0, rc.origin, fill_or_stroke, true, false); - sp_item_gradient_set_coords (SP_ITEM(*i), POINT_LG_END, 0, pt, fill_or_stroke, true, false); + sp_item_gradient_set_coords (*i, POINT_LG_BEGIN, 0, rc.origin, fill_or_stroke, true, false); + sp_item_gradient_set_coords (*i, POINT_LG_END, 0, pt, fill_or_stroke, true, false); } else if (type == SP_GRADIENT_TYPE_RADIAL) { - sp_item_gradient_set_coords (SP_ITEM(*i), POINT_RG_CENTER, 0, rc.origin, fill_or_stroke, true, false); - sp_item_gradient_set_coords (SP_ITEM(*i), POINT_RG_R1, 0, pt, fill_or_stroke, true, false); + sp_item_gradient_set_coords (*i, POINT_RG_CENTER, 0, rc.origin, fill_or_stroke, true, false); + sp_item_gradient_set_coords (*i, POINT_RG_R1, 0, pt, fill_or_stroke, true, false); } SP_OBJECT(*i)->requestModified(SP_OBJECT_MODIFIED_FLAG); } @@ -949,7 +943,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta ec->_grdrag->local_change = true; // give the grab out-of-bounds values of xp/yp because we're already dragging // and therefore are already out of tolerance - ec->_grdrag->grabKnot (SP_ITEM(selection->itemList().front()), + ec->_grdrag->grabKnot (selection->itemList()[0], type == SP_GRADIENT_TYPE_LINEAR? POINT_LG_END : POINT_RG_R1, -1, // ignore number (though it is always 1) fill_or_stroke, 99999, 99999, etime); diff --git a/src/ui/tools/gradient-tool.h b/src/ui/tools/gradient-tool.h index 786aed372..6fe3bca9f 100644 --- a/src/ui/tools/gradient-tool.h +++ b/src/ui/tools/gradient-tool.h @@ -18,7 +18,6 @@ #include #include #include "ui/tools/tool-base.h" -class SPObject;//kill it #define SP_GRADIENT_CONTEXT(obj) (dynamic_cast((Inkscape::UI::Tools::ToolBase*)obj)) #define SP_IS_GRADIENT_CONTEXT(obj) (dynamic_cast((const Inkscape::UI::Tools::ToolBase*)obj) != NULL) @@ -26,12 +25,12 @@ class SPObject;//kill it namespace Inkscape { namespace UI { namespace Tools { -int sp_item_repr_compare_position_obj(SPObject const *first, SPObject const *second);//kill it class GradientTool : public ToolBase { public: GradientTool(); virtual ~GradientTool(); + Geom::Point origin; bool cursor_addnode; diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index 2b44639c8..5295a16c0 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -444,7 +444,7 @@ bool MeasureTool::root_handler(GdkEvent* event) { std::vector items = desktop->getDocument()->getItemsAtPoints(desktop->dkey, points); std::vector intersection_times; for (std::vector::const_iterator i=items.begin();i!=items.end();i++) { - SPItem *item = static_cast(*i); + SPItem *item = *i; if (SP_IS_SHAPE(item)) { calculate_intersections(desktop, item, lineseg, SP_SHAPE(item)->getCurve(), intersection_times); diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 0a34e4855..c8e032089 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -48,7 +48,6 @@ // Mesh specific #include "ui/tools/mesh-tool.h" -#include "ui/tools/gradient-tool.h"//not needed #include "sp-mesh-gradient.h" #include "display/sp-ctrlcurve.h" @@ -478,12 +477,12 @@ bool MeshTool::root_handler(GdkEvent* event) { if (over_line) { // We take the first item in selection, because with doubleclick, the first click // always resets selection to the single object under cursor - sp_mesh_context_split_near_point(this, SP_ITEM(selection->itemList().front()), this->mousepoint_doc, event->button.time); + sp_mesh_context_split_near_point(this, selection->itemList()[0], this->mousepoint_doc, event->button.time); } else { // Create a new gradient with default coordinates. std::vector items=selection->itemList(); for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; SPGradientType new_type = SP_GRADIENT_TYPE_MESH; Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE; @@ -932,12 +931,6 @@ bool MeshTool::root_handler(GdkEvent* event) { return ret; } -/* -int sp_item_repr_compare_position_obj(SPObject const *first, SPObject const *second) -{ - return sp_repr_compare_position(((SPItem*)first)->getRepr(), - ((SPItem*)second)->getRepr())<0; -}*/ static void sp_mesh_drag(MeshTool &rc, Geom::Point const /*pt*/, guint /*state*/, guint32 /*etime*/) { SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop; diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index 25cbf76a4..fbc1a9e6c 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -481,7 +481,7 @@ bool SelectTool::root_handler(GdkEvent* event) { case GDK_2BUTTON_PRESS: if (event->button.button == 1) { if (!selection->isEmpty()) { - SPItem *clicked_item = static_cast(selection->itemList().front()); + SPItem *clicked_item = selection->itemList()[0]; if (dynamic_cast(clicked_item) && !dynamic_cast(clicked_item)) { // enter group if it's not a 3D box desktop->setCurrentLayer(clicked_item); diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index ac41f3a34..d92d326e0 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -553,13 +553,13 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point std::vector const items(selection->itemList()); for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = dynamic_cast(static_cast(*i)); + SPItem *item = *i; g_assert(item != NULL); sp_object_ref(item); } for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = dynamic_cast(static_cast(*i)); + SPItem *item = *i; g_assert(item != NULL); if (is_transform_modes(tc->mode)) { @@ -574,7 +574,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point } for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = dynamic_cast(static_cast(*i)); + SPItem *item = *i; g_assert(item != NULL); sp_object_unref(item); } diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 6f7764506..8c5e4215e 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -1089,7 +1089,7 @@ sp_tweak_dilate (TweakTool *tc, Geom::Point event_p, Geom::Point p, Geom::Point std::vector items=selection->itemList(); for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = dynamic_cast(static_cast(*i)); + SPItem *item = *i; if (is_color_mode (tc->mode)) { if (do_fill || do_stroke || do_opacity) { -- 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/ui/tools/gradient-tool.cpp | 2 +- src/ui/tools/mesh-tool.cpp | 6 +++--- src/ui/tools/node-tool.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 21ad18c26..a9e109b5c 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -934,7 +934,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta sp_item_gradient_set_coords (*i, POINT_RG_CENTER, 0, rc.origin, fill_or_stroke, true, false); sp_item_gradient_set_coords (*i, POINT_RG_R1, 0, pt, fill_or_stroke, true, false); } - SP_OBJECT(*i)->requestModified(SP_OBJECT_MODIFIED_FLAG); + (*i)->requestModified(SP_OBJECT_MODIFIED_FLAG); } if (ec->_grdrag) { ec->_grdrag->updateDraggers(); diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index c8e032089..2c817694e 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -965,13 +965,13 @@ static void sp_mesh_drag(MeshTool &rc, Geom::Point const /*pt*/, guint /*state*/ for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ //FIXME: see above - sp_repr_css_change_recursive(SP_OBJECT(*i)->getRepr(), css, "style"); + sp_repr_css_change_recursive((*i)->getRepr(), css, "style"); - sp_item_set_gradient(SP_ITEM(*i), vector, (SPGradientType) type, fill_or_stroke); + sp_item_set_gradient(*i, vector, (SPGradientType) type, fill_or_stroke); // We don't need to do anything. Mesh is already sized appropriately. - SP_OBJECT(*i)->requestModified(SP_OBJECT_MODIFIED_FLAG); + (*i)->requestModified(SP_OBJECT_MODIFIED_FLAG); } // if (ec->_grdrag) { // ec->_grdrag->updateDraggers(); diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 6ddb379cc..374386686 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -422,7 +422,7 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) { std::vector items=sel->itemList(); for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ - SPObject *obj = static_cast(*i); + SPObject *obj = *i; if (SP_IS_ITEM(obj)) { gather_items(this, NULL, static_cast(obj), SHAPE_ROLE_NORMAL, shapes); -- cgit v1.2.3 From 60bdd590969d1c32c392a8fed15f4ceac4a678d2 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Mon, 27 Apr 2015 01:12:03 +0200 Subject: Just reread the entire diff against trunk. Given the diff size, i must have forgotten things, but hopefully, there are only very few changes of semantics: ->childList is now in the intuitive order (childList()[0] is now firstChild) -> sp_selection_paste_impl is now in the opposite order (change is local to selection-chemistry.cpp, and simplify a few things) -> selection.setReprList now takes the list in the opposite order. It was always the case (the list was always reversed before handing to it) -> a few comparison functions now work "the c++ way": the C way was to return -1 if ab, now they return (bool)(a to_select; SPDocument *doc = item->document; sp_item_list_to_curves (items, selected, to_select); - SPObject* newObj = doc->getObjectByRepr(to_select.back()); + SPObject* newObj = doc->getObjectByRepr(to_select[0]); item = dynamic_cast(newObj); g_assert(item != NULL); selection->add(item); -- cgit v1.2.3 From 643c75ddbbbea2f018050faa1e7e38c71482418a Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Tue, 28 Apr 2015 01:20:57 +0200 Subject: removed a few useless SP_OBJECT() casts (bzr r13922.1.17) --- src/ui/tools/gradient-tool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index bf38b5ca5..526671515 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -913,7 +913,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta for (std::vector::const_iterator i = itemlist.begin();i!=itemlist.end();i++) { //FIXME: see above - sp_repr_css_change_recursive(SP_OBJECT(*i)->getRepr(), css, "style"); + sp_repr_css_change_recursive((*i)->getRepr(), css, "style"); sp_item_set_gradient(*i, vector, (SPGradientType) type, fill_or_stroke); -- cgit v1.2.3 From ba4dbfb351180e0fc4ad57be6e3534fa2ab5cf8c Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Tue, 28 Apr 2015 00:38:31 +0100 Subject: Fix unnecessary inclusion of glibmm/threads.h. This can be resolved by ensuring that glibmm headers always preceed glib.h headers. Same applies with gtkmm/gtk+ etc (bzr r14064) --- src/ui/tools/tool-base.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index a07f2fb86..2eb6d24d9 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -20,10 +20,6 @@ #include "widgets/desktop-widget.h" -#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H -#include -#endif - #include "shortcuts.h" #include "file.h" #include "ui/tools/tool-base.h" -- cgit v1.2.3 From a06c4852edb10e38fce19fd2df3833c03b6a15e4 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Fri, 8 May 2015 00:12:09 +0200 Subject: fix crash when converting a group of objects to path (bzr r14121) --- src/ui/tools/eraser-tool.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 01b75fdb4..0af347bef 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -674,7 +674,9 @@ void EraserTool::set_to_accumulated() { Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); toWorkOn = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints()); } - toWorkOn.erase(find(toWorkOn.begin(),toWorkOn.end(),acid)); + std::vector::iterator element = find(toWorkOn.begin(),toWorkOn.end(),acid); + if(element != toWorkOn.end()) + toWorkOn.erase(element); } else { toWorkOn= selection->itemList(); wasSelection = true; -- cgit v1.2.3 From fbe59eb1913a779115d9c4769a4066d08e30ff44 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Fri, 8 May 2015 00:25:20 +0200 Subject: better fix, using std::remove instead of std::erase (bzr r14122) --- src/ui/tools/eraser-tool.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 0af347bef..8a9db6c72 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -674,9 +674,7 @@ void EraserTool::set_to_accumulated() { Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); toWorkOn = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints()); } - std::vector::iterator element = find(toWorkOn.begin(),toWorkOn.end(),acid); - if(element != toWorkOn.end()) - toWorkOn.erase(element); + std::remove(toWorkOn.begin(),toWorkOn.end(),acid); } else { toWorkOn= selection->itemList(); wasSelection = true; -- cgit v1.2.3 From 57808dd1abe86ae0088a74bd88041321f5df5fb8 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Fri, 8 May 2015 00:45:15 +0200 Subject: fix for stl "remove" (bzr r14123) --- src/ui/tools/eraser-tool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 8a9db6c72..10f8c8694 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -674,7 +674,7 @@ void EraserTool::set_to_accumulated() { Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); toWorkOn = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints()); } - std::remove(toWorkOn.begin(),toWorkOn.end(),acid); + toWorkOn.erase(std::remove(toWorkOn.begin(), toWorkOn.end(), acid), toWorkOn.end()); } else { toWorkOn= selection->itemList(); wasSelection = true; -- cgit v1.2.3 From 48e0423afcb02fe4a0f705d828a0dbdb3106b397 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Fri, 8 May 2015 15:46:25 +0200 Subject: fixes a few of jenkins warnings (bzr r14126) --- src/ui/tools/box3d-tool.cpp | 2 +- src/ui/tools/flood-tool.cpp | 2 +- src/ui/tools/pen-tool.cpp | 15 ++++----------- src/ui/tools/pencil-tool.cpp | 3 --- src/ui/tools/rect-tool.cpp | 1 - src/ui/tools/select-tool.cpp | 1 - 6 files changed, 6 insertions(+), 18 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp index 538e0c7e2..27e755add 100644 --- a/src/ui/tools/box3d-tool.cpp +++ b/src/ui/tools/box3d-tool.cpp @@ -165,7 +165,7 @@ bool Box3dTool::item_handler(SPItem* item, GdkEvent* event) { case GDK_BUTTON_PRESS: if ( event->button.button == 1 && !this->space_panning) { Inkscape::setup_for_drag_start(desktop, this, event); - ret = TRUE; + //ret = TRUE; } break; // motion and release are always on root (why?) diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp index ffd41d97d..748c82717 100644 --- a/src/ui/tools/flood-tool.cpp +++ b/src/ui/tools/flood-tool.cpp @@ -932,7 +932,7 @@ static void sp_flood_do_flood_fill(ToolBase *event_context, GdkEvent *event, boo std::deque::iterator start_sort = fill_queue.begin(); std::deque::iterator end_sort = fill_queue.begin(); unsigned int sort_y = (unsigned int)cp[Geom::Y]; - unsigned int current_y = sort_y; + unsigned int current_y; for (std::deque::iterator i = fill_queue.begin(); i != fill_queue.end(); ++i) { Geom::Point current = *i; diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index daffc7032..be6156fa2 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -762,14 +762,12 @@ bool PenTool::_handleButtonRelease(GdkEventButton const &revent) { } } this->state = PenTool::CONTROL; - ret = true; break; case PenTool::CONTROL: // End current segment this->_endpointSnap(p, revent.state); this->_finishSegment(p, revent.state); this->state = PenTool::POINT; - ret = true; break; case PenTool::CLOSE: // End current segment @@ -783,12 +781,10 @@ bool PenTool::_handleButtonRelease(GdkEventButton const &revent) { } this->_finish(true); this->state = PenTool::POINT; - ret = true; break; case PenTool::STOP: // This is allowed, if we just canceled curve this->state = PenTool::POINT; - ret = true; break; default: break; @@ -823,7 +819,6 @@ bool PenTool::_handleButtonRelease(GdkEventButton const &revent) { break; } this->state = PenTool::POINT; - ret = true; break; default: break; @@ -1432,8 +1427,7 @@ void PenTool::_bsplineSpiroStartAnchorOn() { using Geom::X; using Geom::Y; - SPCurve *tmp_curve = new SPCurve(); - tmp_curve = this->sa->curve->copy(); + SPCurve *tmp_curve = this->sa->curve->copy(); if(this->sa->start) tmp_curve = tmp_curve ->create_reverse(); Geom::CubicBezier const * cubic = dynamic_cast(&*tmp_curve ->last_segment()); @@ -1465,8 +1459,7 @@ void PenTool::_bsplineSpiroStartAnchorOn() void PenTool::_bsplineSpiroStartAnchorOff() { - SPCurve *tmp_curve = new SPCurve(); - tmp_curve = this->sa->curve->copy(); + SPCurve *tmp_curve = this->sa->curve->copy(); if(this->sa->start) tmp_curve = tmp_curve ->create_reverse(); Geom::CubicBezier const * cubic = dynamic_cast(&*tmp_curve ->last_segment()); @@ -1564,7 +1557,7 @@ void PenTool::_bsplineSpiroEndAnchorOn() using Geom::Y; this->p[2] = this->p[3] + (1./3)*(this->p[0] - this->p[3]); this->p[2] = Geom::Point(this->p[2][X] + HANDLE_CUBIC_GAP,this->p[2][Y] + HANDLE_CUBIC_GAP); - SPCurve *tmp_curve = new SPCurve(); + SPCurve *tmp_curve; SPCurve *last_segment = new SPCurve(); Geom::Point point_c(0,0); bool reverse = false; @@ -1621,7 +1614,7 @@ void PenTool::_bsplineSpiroEndAnchorOn() void PenTool::_bsplineSpiroEndAnchorOff() { - SPCurve *tmp_curve = new SPCurve(); + SPCurve *tmp_curve; SPCurve *last_segment = new SPCurve(); bool reverse = false; this->p[2] = this->p[3]; diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index 008804162..ba103fa8e 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -357,7 +357,6 @@ bool PencilTool::_handleButtonRelease(GdkEventButton const &revent) { // Ctrl+click creates a single point so only set context in ADDLINE mode when Ctrl isn't pressed this->state = SP_PENCIL_CONTEXT_ADDLINE; } - ret = true; break; case SP_PENCIL_CONTEXT_ADDLINE: /* Finish segment now */ @@ -371,7 +370,6 @@ bool PencilTool::_handleButtonRelease(GdkEventButton const &revent) { this->_finishEndpoint(); this->state = SP_PENCIL_CONTEXT_IDLE; sp_event_context_discard_delayed_snap_event(this); - ret = true; break; case SP_PENCIL_CONTEXT_FREEHAND: if (revent.state & GDK_MOD1_MASK) { @@ -413,7 +411,6 @@ bool PencilTool::_handleButtonRelease(GdkEventButton const &revent) { // reset sketch mode too this->sketch_n = 0; } - ret = true; break; case SP_PENCIL_CONTEXT_SKETCH: default: diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp index 62a9006ea..844965c4d 100644 --- a/src/ui/tools/rect-tool.cpp +++ b/src/ui/tools/rect-tool.cpp @@ -143,7 +143,6 @@ bool RectTool::item_handler(SPItem* item, GdkEvent* event) { case GDK_BUTTON_PRESS: if ( event->button.button == 1 && !this->space_panning) { Inkscape::setup_for_drag_start(desktop, this, event); - ret = TRUE; } break; // motion and release are always on root (why?) diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index f8375a1bb..f06b03d91 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -777,7 +777,6 @@ bool SelectTool::root_handler(GdkEvent* event) { } rb_escaped = 0; - ret = TRUE; } } } -- cgit v1.2.3