diff options
| author | Marc Jeanmougin <marc@jeanmougin.fr> | 2017-10-01 15:49:26 +0000 |
|---|---|---|
| committer | Marc Jeanmougin <marc@jeanmougin.fr> | 2017-10-01 15:49:26 +0000 |
| commit | e0957537cd0938313803c290a2f3922a3889e6f1 (patch) | |
| tree | 7f158d00a7655ee91ac094f676f6b3bd624a78b7 /src/ui/tools/pen-tool.cpp | |
| parent | Merge branch 'master' of gitlab.com:inkscape/inkscape (diff) | |
| download | inkscape-e0957537cd0938313803c290a2f3922a3889e6f1.tar.gz inkscape-e0957537cd0938313803c290a2f3922a3889e6f1.zip | |
Removed all GSList occurences in .h files
Diffstat (limited to 'src/ui/tools/pen-tool.cpp')
| -rw-r--r-- | src/ui/tools/pen-tool.cpp | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 0db5c3954..f8dfd7a10 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -860,18 +860,18 @@ bool PenTool::_handle2ButtonPress(GdkEventButton const &bevent) { void PenTool::_redrawAll() { // green - if (this->green_bpaths) { + if (! this->green_bpaths.empty()) { // remove old piecewise green canvasitems - while (this->green_bpaths) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data)); - this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data); + for (auto i : this->green_bpaths){ + sp_canvas_item_destroy(i); } + this->green_bpaths.clear(); // one canvas bpath for all of green_curve SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), this->green_curve, true); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvas_shape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(canvas_shape), 0, SP_WIND_RULE_NONZERO); - this->green_bpaths = g_slist_prepend(this->green_bpaths, canvas_shape); + this->green_bpaths.push_back(canvas_shape); } if (this->green_anchor) { SP_CTRL(this->green_anchor->ctrl)->moveto(this->green_anchor->dp); @@ -1253,10 +1253,10 @@ void PenTool::_resetColors() { this->blue_curve->reset(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->blue_bpath), NULL, true); // Green - while (this->green_bpaths) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data)); - this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data); + for (auto i:this->green_bpaths) { + sp_canvas_item_destroy(i); } + this->green_bpaths.clear(); this->green_curve->reset(); if (this->green_anchor) { this->green_anchor = sp_draw_anchor_destroy(this->green_anchor); @@ -1332,17 +1332,17 @@ void PenTool::_bsplineSpiroColor() } //We erase all the "green_bpaths" to recreate them after with the colour //transparency recently modified - if (this->green_bpaths) { + if (!this->green_bpaths.empty()) { // remove old piecewise green canvasitems - while (this->green_bpaths) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data)); - this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data); + for (auto i:this->green_bpaths) { + sp_canvas_item_destroy(i); } + this->green_bpaths.clear(); // one canvas bpath for all of green_curve SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), this->green_curve, true); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvas_shape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(canvas_shape), 0, SP_WIND_RULE_NONZERO); - this->green_bpaths = g_slist_prepend(this->green_bpaths, canvas_shape); + this->green_bpaths.push_back(canvas_shape); } sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(this->red_bpath), this->red_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); } @@ -1555,18 +1555,18 @@ void PenTool::_bsplineSpiroMotion(guint const state){ this->overwrite_curve = tmp_curve->copy(); } } - if (this->green_bpaths) { + if (!this->green_bpaths.empty()) { this->green_curve = tmp_curve->copy(); // remove old piecewise green canvasitems - while (this->green_bpaths) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data)); - this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data); + for (auto i: this->green_bpaths) { + sp_canvas_item_destroy(i); } + this->green_bpaths.clear(); // one canvas bpath for all of green_curve SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), this->green_curve, true); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvas_shape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(canvas_shape), 0, SP_WIND_RULE_NONZERO); - this->green_bpaths = g_slist_prepend(this->green_bpaths, canvas_shape); + this->green_bpaths.push_back(canvas_shape); } } if (cubic) { @@ -1927,7 +1927,7 @@ void PenTool::_finishSegment(Geom::Point const p, guint const state) { curve->unref(); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvas_shape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); - this->green_bpaths = g_slist_prepend(this->green_bpaths, canvas_shape); + this->green_bpaths.push_back(canvas_shape); this->p[0] = this->p[3]; this->p[1] = this->p[4]; @@ -1953,11 +1953,9 @@ bool PenTool::_undoLastPoint() { // Reset red curve this->red_curve->reset(); // Destroy topmost green bpath - if (this->green_bpaths) { - if (this->green_bpaths->data) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data)); - } - this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data); + if (!this->green_bpaths.empty()) { + sp_canvas_item_destroy(this->green_bpaths.back()); + this->green_bpaths.pop_back(); } // Get last segment if ( this->green_curve->is_unset() ) { @@ -1985,11 +1983,9 @@ bool PenTool::_undoLastPoint() { // delete the last segment of the green curve if (this->green_curve->get_segment_count() == 1) { this->npoints = 5; - if (this->green_bpaths) { - if (this->green_bpaths->data) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data)); - } - this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data); + if (!this->green_bpaths.empty()) { + sp_canvas_item_destroy(this->green_bpaths.back()); + this->green_bpaths.pop_back(); } this->green_curve->reset(); } else { |
