From 8bdeca099355f46c4f112144474ca470889dc668 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Fri, 27 Sep 2013 22:05:56 +0200 Subject: cppcheck: performance + variable type (bzr r12603) --- src/libavoid/vertices.h | 2 +- src/libcola/connected_components.cpp | 8 ++++---- src/libcola/cycle_detector.cpp | 4 ++-- src/libcola/gradient_projection.cpp | 2 +- src/libcola/straightener.cpp | 18 +++++++++--------- 5 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/libavoid/vertices.h b/src/libavoid/vertices.h index b07c87f95..619692c23 100644 --- a/src/libavoid/vertices.h +++ b/src/libavoid/vertices.h @@ -129,7 +129,7 @@ class VertInfList unsigned int shapesSize(void) const; void stats(FILE *fp = stderr) { - fprintf(fp, "Conns %d, shapes %d\n", _connVertices, + fprintf(fp, "Conns %u, shapes %u\n", _connVertices, _shapeVertices); } private: diff --git a/src/libcola/connected_components.cpp b/src/libcola/connected_components.cpp index 1afec55b4..823f7cf6e 100644 --- a/src/libcola/connected_components.cpp +++ b/src/libcola/connected_components.cpp @@ -77,7 +77,7 @@ namespace cola { } vector::const_iterator ei; SimpleConstraints::const_iterator ci; - for(ei=es.begin();ei!=es.end();ei++) { + for(ei=es.begin();ei!=es.end();++ei) { vs[ei->first].neighbours.push_back(&vs[ei->second]); vs[ei->second].neighbours.push_back(&vs[ei->first]); } @@ -88,13 +88,13 @@ namespace cola { dfs(v,remaining,component,cmap); components.push_back(component); } - for(ei=es.begin();ei!=es.end();ei++) { + for(ei=es.begin();ei!=es.end();++ei) { pair u=cmap[ei->first], v=cmap[ei->second]; assert(u.first==v.first); u.first->edges.push_back(make_pair(u.second,v.second)); } - for(ci=scx.begin();ci!=scx.end();ci++) { + for(ci=scx.begin();ci!=scx.end();++ci) { SimpleConstraint *c=*ci; pair u=cmap[c->left], v=cmap[c->right]; @@ -102,7 +102,7 @@ namespace cola { u.first->scx.push_back( new SimpleConstraint(u.second,v.second,c->gap)); } - for(ci=scy.begin();ci!=scy.end();ci++) { + for(ci=scy.begin();ci!=scy.end();++ci) { SimpleConstraint *c=*ci; pair u=cmap[c->left], v=cmap[c->right]; diff --git a/src/libcola/cycle_detector.cpp b/src/libcola/cycle_detector.cpp index 89a2ccaae..11e24a0ba 100644 --- a/src/libcola/cycle_detector.cpp +++ b/src/libcola/cycle_detector.cpp @@ -53,7 +53,7 @@ void CycleDetector::make_matrix() { assert(traverse.empty()); // from the edges passed, fill the adjacency matrix - for (ei = edges->begin(); ei != edges->end(); ei++) { + for (ei = edges->begin(); ei != edges->end(); ++ei) { anEdge = *ei; // the matrix is indexed by the first vertex of the edge // the second vertex of the edge is pushed onto another @@ -241,7 +241,7 @@ bool CycleDetector::find_node(std::vector *& list, unsigned k) { } pair< bool, vector::iterator > CycleDetector::find_node(std::vector& list, unsigned k) { - for (vector::iterator ti = traverse.begin(); ti != traverse.end(); ti++) { + for (vector::iterator ti = traverse.begin(); ti != traverse.end(); ++ti) { if (*ti == k) { return pair< bool, vector::iterator >(true, ti); } } diff --git a/src/libcola/gradient_projection.cpp b/src/libcola/gradient_projection.cpp index 47109a4b0..3e41aceac 100644 --- a/src/libcola/gradient_projection.cpp +++ b/src/libcola/gradient_projection.cpp @@ -222,7 +222,7 @@ void GradientProjection::destroyVPSC(IncSolver *vpsc) { delete vpsc; delete [] cs; delete [] vs; - for(vector::iterator i=lcs.begin();i!=lcs.end();i++) { + for(vector::iterator i=lcs.begin();i!=lcs.end();++i) { delete *i; } lcs.clear(); diff --git a/src/libcola/straightener.cpp b/src/libcola/straightener.cpp index 650f41aac..fab30d48d 100644 --- a/src/libcola/straightener.cpp +++ b/src/libcola/straightener.cpp @@ -90,7 +90,7 @@ namespace straightener { ds.erase(copyit); } } - for(set >::iterator j=pntsOnLineSegment.begin();j!=pntsOnLineSegment.end();j++) { + for(set >::iterator j=pntsOnLineSegment.begin();j!=pntsOnLineSegment.end();++j) { path.push_back(j->second); } //printf("\n"); @@ -144,11 +144,11 @@ namespace straightener { e->ypos(conjpos,bs); } //cerr << "edge(intersections="<startNode<<","<endNode<<"))"<::iterator it=bs.begin();it!=bs.end();it++) { + for(vector::iterator it=bs.begin();it!=bs.end();++it) { sortedEdges.insert(make_pair(*it,e)); } } - for(set::iterator i=sortedEdges.begin();i!=sortedEdges.end();i++) { + for(set::iterator i=sortedEdges.begin();i!=sortedEdges.end();++i) { double pos=i->first; if(pos < minpos) continue; if(pos > v->scanpos) break; @@ -169,7 +169,7 @@ namespace straightener { if(r!=NULL) { maxpos=r->scanpos; } - for(set::iterator i=sortedEdges.begin();i!=sortedEdges.end();i++) { + for(set::iterator i=sortedEdges.begin();i!=sortedEdges.end();++i) { if(i->first < v->scanpos) continue; if(i->first > maxpos) break; double pos=i->first; @@ -262,7 +262,7 @@ namespace straightener { // Case A: create constraints between adjacent edges skipping edges joined // to l,v or r. Node* lastNode=NULL; - for(vector::iterator i=L.begin();i!=L.end();i++) { + for(vector::iterator i=L.begin();i!=L.end();++i) { if((*i)->dummy) { // node is on an edge Edge *edge=(*i)->edge; @@ -284,7 +284,7 @@ namespace straightener { // their own end, also in the scan line vector skipList; lastNode=NULL; - for(vector::iterator i=L.begin();i!=L.end();i++) { + for(vector::iterator i=L.begin();i!=L.end();++i) { if((*i)->dummy) { // node is on an edge if(lastNode!=NULL) { @@ -292,7 +292,7 @@ namespace straightener { skipList.push_back(*i); } else { for(vector::iterator j=skipList.begin(); - j!=skipList.end();j++) { + j!=skipList.end();++j) { //printf(" Rule B: Constraint: v%d +g <= v%d\n",(*j)->id,(*i)->id); cs.push_back(createConstraint(*j,*i,dim)); } @@ -309,7 +309,7 @@ namespace straightener { skipList.clear(); // Case C: reverse of B lastNode=NULL; - for(vector::reverse_iterator i=L.rbegin();i!=L.rend();i++) { + for(vector::reverse_iterator i=L.rbegin();i!=L.rend();++i) { if((*i)->dummy) { // node is on an edge if(lastNode!=NULL) { @@ -317,7 +317,7 @@ namespace straightener { skipList.push_back(*i); } else { for(vector::iterator j=skipList.begin(); - j!=skipList.end();j++) { + j!=skipList.end();++j) { //printf(" Rule C: Constraint: v%d +g <= v%d\n",(*i)->id,(*j)->id); cs.push_back(createConstraint(*i,*j,dim)); } -- cgit v1.2.3 From ad925e4014535e5f21794ee8ece424ffa83f94e5 Mon Sep 17 00:00:00 2001 From: buliabyak <> Date: Sat, 28 Sep 2013 01:09:04 -0300 Subject: bug fix: xml:space was not initialized, getting random values (bzr r12604) --- src/sp-object.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/sp-object.h b/src/sp-object.h index 4e9a6c938..bcaa1dac7 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -106,7 +106,9 @@ enum { class SPDocument; /// Internal class consisting of two bits. -struct SPIXmlSpace { +class SPIXmlSpace { +public: + SPIXmlSpace(): set(0), value(SP_XML_SPACE_DEFAULT) {}; guint set : 1; guint value : 1; }; -- cgit v1.2.3 From a5e764ae43d4b3ba1d7cb63c9cfdb3f1b9e1b13e Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Sat, 28 Sep 2013 00:12:30 -0400 Subject: Allow pixmaps to specify their width and height to control/knots. Allows non-square nodes. (bzr r12605) --- src/display/sodipodi-ctrl.cpp | 191 +++++++++++++++++------------------------- src/display/sodipodi-ctrl.h | 4 +- src/knot.cpp | 30 ++----- 3 files changed, 83 insertions(+), 142 deletions(-) (limited to 'src') diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp index 45dc38a37..3636319df 100644 --- a/src/display/sodipodi-ctrl.cpp +++ b/src/display/sodipodi-ctrl.cpp @@ -108,81 +108,50 @@ sp_ctrl_set_property(GObject *object, guint prop_id, const GValue *value, GParam ctrl = SP_CTRL (object); switch (prop_id) { - case ARG_SHAPE: { - ctrl->shape = (SPCtrlShapeType) g_value_get_int(value); - ctrl->build = FALSE; - sp_canvas_item_request_update(item); - } - break; - - case ARG_MODE: { - ctrl->mode = (SPCtrlModeType) g_value_get_int(value); - ctrl->build = FALSE; - sp_canvas_item_request_update(item); - } - break; - - case ARG_ANCHOR: { - ctrl->anchor = (SPAnchorType) g_value_get_int(value); - ctrl->build = FALSE; - sp_canvas_item_request_update(item); - } - break; - - case ARG_SIZE: { - ctrl->span = (gint)((g_value_get_double(value) - 1.0) / 2.0 + 0.5); - ctrl->defined = (ctrl->span > 0); - ctrl->build = FALSE; - sp_canvas_item_request_update(item); - } - break; - - case ARG_FILLED: { - ctrl->filled = g_value_get_boolean(value); - ctrl->build = FALSE; - sp_canvas_item_request_update(item); - } - break; - - case ARG_FILL_COLOR: { - guint32 fill = g_value_get_int(value); - ctrl->fill_color = fill; - ctrl->build = FALSE; - sp_canvas_item_request_update(item); - } - break; - - case ARG_STROKED: { - ctrl->stroked = g_value_get_boolean(value); - ctrl->build = FALSE; - sp_canvas_item_request_update(item); - } - break; - - case ARG_STROKE_COLOR: { - guint32 stroke = g_value_get_int(value); - ctrl->stroke_color = stroke; - ctrl->build = FALSE; - sp_canvas_item_request_update(item); - } - break; - - case ARG_PIXBUF: { - pixbuf = (GdkPixbuf*) g_value_get_pointer(value); - if (gdk_pixbuf_get_has_alpha(pixbuf)) { - ctrl->pixbuf = pixbuf; - } else { - ctrl->pixbuf = gdk_pixbuf_add_alpha(pixbuf, FALSE, 0, 0, 0); - g_object_unref(pixbuf); - } - ctrl->build = FALSE; - } - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; + case ARG_SHAPE: + ctrl->shape = (SPCtrlShapeType) g_value_get_int(value); + break; + case ARG_MODE: + ctrl->mode = (SPCtrlModeType) g_value_get_int(value); + break; + case ARG_ANCHOR: + ctrl->anchor = (SPAnchorType) g_value_get_int(value); + break; + case ARG_SIZE: + ctrl->width = (gint)(g_value_get_double(value) / 2.0); + ctrl->height = ctrl->width; + ctrl->defined = (ctrl->width > 0); + break; + case ARG_FILLED: + ctrl->filled = g_value_get_boolean(value); + break; + case ARG_FILL_COLOR: + ctrl->fill_color = (guint32)g_value_get_int(value); + break; + case ARG_STROKED: + ctrl->stroked = g_value_get_boolean(value); + break; + case ARG_STROKE_COLOR: + ctrl->stroke_color = (guint32)g_value_get_int(value); + break; + case ARG_PIXBUF: + pixbuf = (GdkPixbuf*) g_value_get_pointer(value); + // A pixbuf defines it's own size, don't mess about with size. + ctrl->width = gdk_pixbuf_get_width(pixbuf) / 2.0; + ctrl->height = gdk_pixbuf_get_height(pixbuf) / 2.0; + if (gdk_pixbuf_get_has_alpha(pixbuf)) { + ctrl->pixbuf = pixbuf; + } else { + ctrl->pixbuf = gdk_pixbuf_add_alpha(pixbuf, FALSE, 0, 0, 0); + g_object_unref(pixbuf); + } + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + return; // Do not do an update } + ctrl->build = FALSE; + sp_canvas_item_request_update(item); } static void @@ -206,7 +175,7 @@ sp_ctrl_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec break; case ARG_SIZE: - g_value_set_double(value, ctrl->span); + g_value_set_double(value, ctrl->width); break; case ARG_FILLED: @@ -241,7 +210,8 @@ sp_ctrl_init (SPCtrl *ctrl) ctrl->shape = SP_CTRL_SHAPE_SQUARE; ctrl->mode = SP_CTRL_MODE_COLOR; ctrl->anchor = SP_ANCHOR_CENTER; - ctrl->span = 3; + ctrl->width = 3; + ctrl->height = 3; ctrl->defined = TRUE; ctrl->shown = FALSE; ctrl->build = FALSE; @@ -250,12 +220,6 @@ sp_ctrl_init (SPCtrl *ctrl) ctrl->fill_color = 0x000000ff; ctrl->stroke_color = 0x000000ff; - // This way we make sure that the first sp_ctrl_update() call finishes properly; - // in subsequent calls it will not update anything it the control hasn't moved - // Consider for example the case in which a snap indicator is drawn at (0, 0); - // If moveto() is called then it will not set _moved to true because we're initially already at (0, 0) - ctrl->_moved = true; // Is this flag ever going to be set back to false? I can't find where that is supposed to happen - new (&ctrl->box) Geom::IntRect(0,0,0,0); ctrl->cache = NULL; ctrl->pixbuf = NULL; @@ -292,16 +256,14 @@ sp_ctrl_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int fla sp_canvas_item_reset_bounds (item); - if (!ctrl->_moved) return; - if (ctrl->shown) { item->canvas->requestRedraw(ctrl->box.left(), ctrl->box.top(), ctrl->box.right() + 1, ctrl->box.bottom() + 1); } if (!ctrl->defined) return; - x = (gint) ((affine[4] > 0) ? (affine[4] + 0.5) : (affine[4] - 0.5)) - ctrl->span; - y = (gint) ((affine[5] > 0) ? (affine[5] + 0.5) : (affine[5] - 0.5)) - ctrl->span; + x = (gint) ((affine[4] > 0) ? (affine[4] + 0.5) : (affine[4] - 0.5)) - ctrl->width; + y = (gint) ((affine[5] > 0) ? (affine[5] + 0.5) : (affine[5] - 0.5)) - ctrl->height; switch (ctrl->anchor) { case SP_ANCHOR_N: @@ -312,13 +274,13 @@ sp_ctrl_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int fla case SP_ANCHOR_NW: case SP_ANCHOR_W: case SP_ANCHOR_SW: - x += ctrl->span; + x += ctrl->width; break; case SP_ANCHOR_NE: case SP_ANCHOR_E: case SP_ANCHOR_SE: - x -= (ctrl->span + 1); + x -= (ctrl->width + 1); break; } @@ -331,17 +293,17 @@ sp_ctrl_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int fla case SP_ANCHOR_NW: case SP_ANCHOR_N: case SP_ANCHOR_NE: - y += ctrl->span; + y += ctrl->height; break; case SP_ANCHOR_SW: case SP_ANCHOR_S: case SP_ANCHOR_SE: - y -= (ctrl->span + 1); + y -= (ctrl->height + 1); break; } - ctrl->box = Geom::IntRect::from_xywh(x, y, 2*ctrl->span, 2*ctrl->span); + ctrl->box = Geom::IntRect::from_xywh(x, y, 2*ctrl->width, 2*ctrl->height); sp_canvas_update_bbox (item, ctrl->box.left(), ctrl->box.top(), ctrl->box.right() + 1, ctrl->box.bottom() + 1); } @@ -360,7 +322,7 @@ static void sp_ctrl_build_cache (SPCtrl *ctrl) { guint32 *p, *q; - gint size, x, y, z, s, a, side, c; + gint size, x, y, z, s, a, width, height, c; guint32 stroke_color, fill_color; if (ctrl->filled) { @@ -382,11 +344,11 @@ sp_ctrl_build_cache (SPCtrl *ctrl) stroke_color = fill_color; } - - side = (ctrl->span * 2 +1); - c = ctrl->span; - size = side * side; - if (side < 2) return; + width = (ctrl->width * 2 +1); + height = (ctrl->height * 2 +1); + c = ctrl->width; // Only used for pre-set square drawing + size = width * height; + if (width < 2) return; if (ctrl->cache) delete[] ctrl->cache; ctrl->cache = new guint32[size]; @@ -395,19 +357,19 @@ sp_ctrl_build_cache (SPCtrl *ctrl) case SP_CTRL_SHAPE_SQUARE: p = ctrl->cache; // top edge - for (x=0; x < side; x++) { + for (x=0; x < width; x++) { *p++ = stroke_color; } // middle - for (y = 2; y < side; y++) { + for (y = 2; y < height; y++) { *p++ = stroke_color; // stroke at first and last pixel - for (x=2; x < side; x++) { + for (x=2; x < width; x++) { *p++ = fill_color; // fill in the middle } *p++ = stroke_color; } // bottom edge - for (x=0; x < side; x++) { + for (x=0; x < width; x++) { *p++ = stroke_color; } ctrl->build = TRUE; @@ -415,19 +377,19 @@ sp_ctrl_build_cache (SPCtrl *ctrl) case SP_CTRL_SHAPE_DIAMOND: p = ctrl->cache; - for (y = 0; y < side; y++) { + for (y = 0; y < height; y++) { z = abs (c - y); for (x = 0; x < z; x++) { *p++ = 0; } *p++ = stroke_color; x++; - for (; x < side - z -1; x++) { + for (; x < width - z -1; x++) { *p++ = fill_color; } if (z != c) { *p++ = stroke_color; x++; } - for (; x < side; x++) { + for (; x < width; x++) { *p++ = 0; } } @@ -462,7 +424,7 @@ sp_ctrl_build_cache (SPCtrl *ctrl) *q-- = stroke_color; x++; } while (x <= c+z); - while (x < side) { + while (x < width) { *p++ = 0; *q-- = 0; x++; @@ -474,7 +436,7 @@ sp_ctrl_build_cache (SPCtrl *ctrl) case SP_CTRL_SHAPE_CROSS: p = ctrl->cache; - for (y = 0; y < side; y++) { + for (y = 0; y < height; y++) { z = abs (c - y); for (x = 0; x < c-z; x++) { *p++ = 0; @@ -486,7 +448,7 @@ sp_ctrl_build_cache (SPCtrl *ctrl) if (z != 0) { *p++ = stroke_color; x++; } - for (; x < side; x++) { + for (; x < width; x++) { *p++ = 0; } } @@ -499,12 +461,12 @@ sp_ctrl_build_cache (SPCtrl *ctrl) unsigned int rs; px = gdk_pixbuf_get_pixels (ctrl->pixbuf); rs = gdk_pixbuf_get_rowstride (ctrl->pixbuf); - for (y = 0; y < side; y++){ + for (y = 0; y < height; y++){ guint32 *d; unsigned char *s; s = px + y * rs; - d = ctrl->cache + side * y; - for (x = 0; x < side; x++) { + d = ctrl->cache + height * y; + for (x = 0; x < width; x++) { if (s[3] < 0x80) { *d++ = 0; } else if (s[0] < 0x80) { @@ -527,9 +489,9 @@ sp_ctrl_build_cache (SPCtrl *ctrl) guint32 *px; guchar *data = gdk_pixbuf_get_pixels (ctrl->pixbuf); p = ctrl->cache; - for (y = 0; y < side; y++){ + for (y = 0; y < height; y++){ px = reinterpret_cast(data + y * r); - for (x = 0; x < side; x++) { + for (x = 0; x < width; x++) { *p++ = *px++; } } @@ -566,8 +528,8 @@ sp_ctrl_render (SPCanvasItem *item, SPCanvasBuf *buf) sp_ctrl_build_cache (ctrl); } - int w, h; - w = h = (ctrl->span * 2 +1); + int w = (ctrl->width * 2 + 1); + int h = (ctrl->height * 2 + 1); // The code below works even when the target is not an image surface if (ctrl->mode == SP_CTRL_MODE_XOR) { @@ -627,7 +589,6 @@ sp_ctrl_render (SPCanvasItem *item, SPCanvasBuf *buf) void SPCtrl::moveto (Geom::Point const p) { if (p != _point) { sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (this), Geom::Affine(Geom::Translate (p))); - _moved = true; } _point = p; } diff --git a/src/display/sodipodi-ctrl.h b/src/display/sodipodi-ctrl.h index cd0fcadf1..ecdb896a7 100644 --- a/src/display/sodipodi-ctrl.h +++ b/src/display/sodipodi-ctrl.h @@ -37,7 +37,8 @@ struct SPCtrl : public SPCanvasItem { SPCtrlShapeType shape; SPCtrlModeType mode; SPAnchorType anchor; - gint span; + gint width; + gint height; guint defined : 1; guint shown : 1; guint build : 1; @@ -45,7 +46,6 @@ struct SPCtrl : public SPCanvasItem { guint stroked : 1; guint32 fill_color; guint32 stroke_color; - bool _moved; Geom::IntRect box; /* NB! x1 & y1 are included */ guint32 *cache; diff --git a/src/knot.cpp b/src/knot.cpp index 890abd0a1..2b67440dc 100644 --- a/src/knot.cpp +++ b/src/knot.cpp @@ -646,34 +646,14 @@ void sp_knot_update_ctrl(SPKnot *knot) */ static void sp_knot_set_ctrl_state(SPKnot *knot) { + int state = SP_KNOT_STATE_NORMAL; if (knot->flags & SP_KNOT_DRAGGING) { - g_object_set(knot->item, - "fill_color", - knot->fill[SP_KNOT_STATE_DRAGGING], - NULL); - g_object_set(knot->item, - "stroke_color", - knot->stroke[SP_KNOT_STATE_DRAGGING], - NULL); + state = SP_KNOT_STATE_DRAGGING; } else if (knot->flags & SP_KNOT_MOUSEOVER) { - g_object_set(knot->item, - "fill_color", - knot->fill[SP_KNOT_STATE_MOUSEOVER], - NULL); - g_object_set(knot->item, - "stroke_color", - knot->stroke[SP_KNOT_STATE_MOUSEOVER], - NULL); - } else { - g_object_set(knot->item, - "fill_color", - knot->fill[SP_KNOT_STATE_NORMAL], - NULL); - g_object_set(knot->item, - "stroke_color", - knot->stroke[SP_KNOT_STATE_NORMAL], - NULL); + state = SP_KNOT_STATE_MOUSEOVER; } + g_object_set(knot->item, "fill_color", knot->fill[state], NULL); + g_object_set(knot->item, "stroke_color", knot->stroke[state], NULL); } -- cgit v1.2.3 From 4dc2e0a91fc261f2c3cbc23e3b37cf9c1485d64c Mon Sep 17 00:00:00 2001 From: buliabyak <> Date: Sat, 28 Sep 2013 10:56:40 -0300 Subject: obvious memleak (bzr r12606) --- src/number-opt-number.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/number-opt-number.h b/src/number-opt-number.h index 867d0535f..d9ab56102 100644 --- a/src/number-opt-number.h +++ b/src/number-opt-number.h @@ -120,6 +120,8 @@ public: _set = FALSE; optNumber_set = FALSE; } + + g_strfreev(values); } }; -- cgit v1.2.3 From d34822965a4fe7bab4e509c93b144ad1cabfa644 Mon Sep 17 00:00:00 2001 From: buliabyak <> Date: Sat, 28 Sep 2013 10:59:58 -0300 Subject: leak fixes: free marker value on delete; free the return value of uri's toString() (bzr r12607) --- src/style.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/style.cpp b/src/style.cpp index 2807a7d9a..bea56e7b1 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -593,10 +593,18 @@ sp_style_unref(SPStyle *style) sp_style_filter_clear(style); g_free(style->stroke_dash.dash); + + for (unsigned i = SP_MARKER_LOC; i < SP_MARKER_LOC_QTY; i++) { + if (style->marker[i].value) { + g_free(style->marker[i].value); + style->marker[i].value = NULL; + } + } + g_free(style); + return NULL; } - - return NULL; + return style; } /** @@ -4447,6 +4455,7 @@ sp_style_write_ipaint(gchar *b, gint const len, gchar const *const key, if ( paint->value.href && paint->value.href->getURI() ) { const gchar* uri = paint->value.href->getURI()->toString(); css << "url(" << uri << ")"; + g_free((void *)uri); } if ( paint->noneSet ) { @@ -4631,7 +4640,10 @@ sp_style_write_ifilter(gchar *p, gint const len, gchar const *key, if (val->inherit) { return g_snprintf(p, len, "%s:inherit;", key); } else if (val->href && val->href->getURI()) { - return g_snprintf(p, len, "%s:url(%s);", key, val->href->getURI()->toString()); + gchar *uri = val->href->getURI()->toString(); + gint ret = g_snprintf(p, len, "%s:url(%s);", key, uri); + g_free(uri); + return ret; } } -- cgit v1.2.3 From 45bdb1d8bdfe52de31ca28a2a26d4d1204bb9961 Mon Sep 17 00:00:00 2001 From: buliabyak <> Date: Sat, 28 Sep 2013 11:04:26 -0300 Subject: on hiding, texts must _clearFlow to release arena items, otherwise they leak (bzr r12608) --- src/sp-flowtext.cpp | 7 ++++++- src/sp-text.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index 88564c0ac..266e9dfe0 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -326,7 +326,12 @@ Inkscape::DrawingItem* SPFlowtext::show(Inkscape::Drawing &drawing, unsigned int } void SPFlowtext::hide(unsigned int key) { - SPItem::hide(key); + for (SPItemView* v = this->display; v != NULL; v = v->next) { + if (v->key == key) { + Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); + this->_clearFlow(g); + } + } } diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 72a5996d1..c515828a4 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -318,7 +318,12 @@ Inkscape::DrawingItem* SPText::show(Inkscape::Drawing &drawing, unsigned key, un void SPText::hide(unsigned int key) { -// SPItem::onHide(key); + for (SPItemView* v = this->display; v != NULL; v = v->next) { + if (v->key == key) { + Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); + this->_clearFlow(g); + } + } } const char* SPText::displayName() { -- cgit v1.2.3 From f9a958922e109295c9f4f3c12e5716ebf07a6dad Mon Sep 17 00:00:00 2001 From: buliabyak <> Date: Sat, 28 Sep 2013 11:50:34 -0300 Subject: return value of g_utf16_to_utf8 was leaking here (bzr r12609) --- src/inkscape.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/inkscape.cpp b/src/inkscape.cpp index e1cabd2d5..cce4ca5b9 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -1483,7 +1483,9 @@ profile_path(const char *filename) } if (prefdir) { - prefdir = g_build_filename(prefdir, INKSCAPE_PROFILE_DIR, NULL); + const char *prefdir_profile = g_build_filename(prefdir, INKSCAPE_PROFILE_DIR, NULL); + g_free((void *)prefdir); + prefdir = prefdir_profile; } } #endif -- cgit v1.2.3 From e3fe3144bd276bbab4b52aa5d65ac7d487989ff5 Mon Sep 17 00:00:00 2001 From: buliabyak <> Date: Sat, 28 Sep 2013 13:57:04 -0300 Subject: another place where getURI()->toString() values were leaking (bzr r12610) --- src/sp-item.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index a99bf85cc..89e995b5f 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -665,16 +665,20 @@ Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::X if (item->clip_ref){ if (item->clip_ref->getObject()) { - const gchar *value = g_strdup_printf ("url(%s)", item->clip_ref->getURI()->toString()); + gchar *uri = item->clip_ref->getURI()->toString(); + const gchar *value = g_strdup_printf ("url(%s)", uri); repr->setAttribute ("clip-path", value); g_free ((void *) value); + g_free ((void *) uri); } } if (item->mask_ref){ if (item->mask_ref->getObject()) { - const gchar *value = g_strdup_printf ("url(%s)", item->mask_ref->getURI()->toString()); + gchar *uri = item->mask_ref->getURI()->toString(); + const gchar *value = g_strdup_printf ("url(%s)", uri); repr->setAttribute ("mask", value); g_free ((void *) value); + g_free ((void *) uri); } } -- cgit v1.2.3 From ae4fb171df25c328e398d0cf1909a4cbad33a897 Mon Sep 17 00:00:00 2001 From: buliabyak <> Date: Sat, 28 Sep 2013 13:58:09 -0300 Subject: dying document needs to delete its perspective (bzr r12611) --- src/document.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index 800f2f33d..dda072283 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -219,6 +219,11 @@ SPDocument::~SPDocument() { inkscape_unref(); keepalive = FALSE; } + + if (this->current_persp3d_impl) + delete this->current_persp3d_impl; + this->current_persp3d_impl = NULL; + //delete this->_whiteboard_session_manager; } -- cgit v1.2.3 From f1d2cd8504b1d7171b86d13130920297cd474aaf Mon Sep 17 00:00:00 2001 From: buliabyak <> Date: Sat, 28 Sep 2013 15:37:37 -0300 Subject: components of _image_name were g_strdup'ed so need to be g_free'd (bzr r12612) --- src/sp-filter.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index 91389bf7d..1a5c65be9 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -114,6 +114,10 @@ void SPFilter::release() { this->href = NULL; } + for (map::const_iterator i = this->_image_name->begin() ; i != this->_image_name->end() ; i++) { + g_free(i->first); + } + delete this->_image_name; SPObject::release(); -- cgit v1.2.3 From 6ee13490aaa9781b765589e22fb9206c6cb7e9e9 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 28 Sep 2013 20:47:16 +0200 Subject: Fixed MeasureContext. Fixed bugs: - https://launchpad.net/bugs/1232494 (bzr r12613) --- src/measure-context.cpp | 4 ---- src/measure-context.h | 6 ++++++ 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 9d8dc2b2f..7570e36e7 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -309,10 +309,6 @@ static void calculate_intersections(SPDesktop * /*desktop*/, SPItem* item, Geom: } bool SPMeasureContext::root_handler(GdkEvent* event) { - Geom::Point start_point; - boost::optional explicitBase; - boost::optional lastEnd; - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); diff --git a/src/measure-context.h b/src/measure-context.h index e42265045..7d5a88ab7 100644 --- a/src/measure-context.h +++ b/src/measure-context.h @@ -13,6 +13,8 @@ */ #include "event-context.h" +#include <2geom/point.h> +#include #define SP_MEASURE_CONTEXT(obj) (dynamic_cast((SPEventContext*)obj)) #define SP_IS_MEASURE_CONTEXT(obj) (dynamic_cast((const SPEventContext*)obj) != NULL) @@ -31,6 +33,10 @@ public: private: SPCanvasItem* grabbed; + + Geom::Point start_point; + boost::optional explicitBase; + boost::optional lastEnd; }; #endif // SEEN_SP_MEASURING_CONTEXT_H -- cgit v1.2.3 From bdcd0645191270e9136557237f7c48ca5944fc73 Mon Sep 17 00:00:00 2001 From: buliabyak <> Date: Sat, 28 Sep 2013 15:49:01 -0300 Subject: fix one code path where fullname wasn't freed (bzr r12614) --- src/sp-image.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 05dfb5f48..f2fc6a37a 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -682,11 +682,12 @@ Inkscape::Pixbuf *sp_image_repr_read_image(gchar const *href, gchar const *absre // and if it fails, we also try to use bare href regardless of its g_path_is_absolute if (g_file_test (fullname, G_FILE_TEST_EXISTS) && !g_file_test (fullname, G_FILE_TEST_IS_DIR)) { inkpb = Inkscape::Pixbuf::create_from_file(fullname); - g_free (fullname); if (inkpb != NULL) { + g_free (fullname); return inkpb; } } + g_free (fullname); } /* try filename as absolute */ -- cgit v1.2.3 From cfb97f009e1a5f7e6908f53b7af47cf4d93614f6 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 28 Sep 2013 21:02:40 +0200 Subject: Fixed crash with calligraphic tool in subtract mode. Fixed bugs: - https://launchpad.net/bugs/1230007 (bzr r12615) --- src/dyna-draw-context.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index 01f71f76a..f8980e218 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -954,9 +954,20 @@ void SPDynaDrawContext::set_to_accumulated(bool unionize, bool subtract) { } } - SPItem *item=SP_ITEM(desktop->doc()->getObjectByRepr(this->repr)); - item->doWriteTransform(item->getRepr(), item->transform, NULL, true); + // Now we need to write the transform information. + // First, find out whether our repr is still linked to a valid object. In this case, + // we need to write the transform data only for this element. + // Either there was no boolean op or it failed. + SPItem *result = SP_ITEM(desktop->doc()->getObjectByRepr(this->repr)); + + if (result == NULL) { + // The boolean operation succeeded. + // Now we fetch the single item, that has been set as selected by the boolean op. + // This is its result. + result = desktop->getSelection()->singleItem(); + } + result->doWriteTransform(result->getRepr(), result->transform, NULL, true); } else { if (this->repr) { sp_repr_unparent(this->repr); -- cgit v1.2.3 From 6e867cb6aa8b44a3bb9f2dec4361c67cefc8ca8f Mon Sep 17 00:00:00 2001 From: buliabyak <> Date: Sat, 28 Sep 2013 16:20:27 -0300 Subject: effects don't need to merge into menus if we're running without gui; with this we can purge a redundant reading of menus skeleton, which leaked its xml tree (bzr r12616) --- src/extension/effect.cpp | 2 +- src/extension/init.cpp | 2 -- src/inkscape.cpp | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp index dcccf3d7d..1575c2b10 100644 --- a/src/extension/effect.cpp +++ b/src/extension/effect.cpp @@ -89,7 +89,7 @@ Effect::Effect (Inkscape::XML::Node * in_repr, Implementation::Implementation * } // children of "inkscape-extension" } // if we have an XML file - if (INKSCAPE != NULL) { + if (INKSCAPE != NULL && inkscape_use_gui()) { if (_effects_list == NULL) _effects_list = find_menu(inkscape_get_menus(INKSCAPE), EFFECTS_LIST); if (_filters_list == NULL) diff --git a/src/extension/init.cpp b/src/extension/init.cpp index 2dde9eeb8..0ff4b79c4 100644 --- a/src/extension/init.cpp +++ b/src/extension/init.cpp @@ -109,8 +109,6 @@ #include "init.h" -extern gboolean inkscape_app_use_gui( Inkscape::Application const *app ); - namespace Inkscape { namespace Extension { diff --git a/src/inkscape.cpp b/src/inkscape.cpp index cce4ca5b9..228841362 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -502,7 +502,7 @@ inkscape_init (SPObject * object) new (&inkscape->document_set) std::map(); new (&inkscape->selection_models) std::map(); - inkscape->menus = sp_repr_read_mem (_(menus_skeleton), MENUS_SKELETON_SIZE, NULL); + inkscape->menus = NULL; inkscape->desktops = NULL; inkscape->dialogs_toggle = TRUE; inkscape->mapalt = GDK_MOD1_MASK; -- cgit v1.2.3 From 0b3a91c8ff18bd30b42beb71244ff9b0542ed2ca Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 28 Sep 2013 21:58:24 +0200 Subject: fix two memleaks (bzr r12617) --- src/ui/dialog/svg-fonts-dialog.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index ab5f4c0e9..56ecfdecc 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -541,7 +541,9 @@ void SvgFontsDialog::set_glyph_description_from_selected_path(){ Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d")); //XML Tree being directly used here while it shouldn't be. - glyph->getRepr()->setAttribute("d", (char*) sp_svg_write_path (flip_coordinate_system(pathv))); + gchar *str = sp_svg_write_path (flip_coordinate_system(pathv)); + glyph->getRepr()->setAttribute("d", str); + g_free(str); DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); update_glyphs(); @@ -578,7 +580,9 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){ if (SP_IS_MISSING_GLYPH(obj)){ //XML Tree being directly used here while it shouldn't be. - obj->getRepr()->setAttribute("d", (char*) sp_svg_write_path (flip_coordinate_system(pathv))); + gchar *str = sp_svg_write_path (flip_coordinate_system(pathv)); + obj->getRepr()->setAttribute("d", str); + g_free(str); DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); } } -- cgit v1.2.3 From c83329cdf1c37fd1ee123a0f30e8b6582ac51547 Mon Sep 17 00:00:00 2001 From: buliabyak <> Date: Sat, 28 Sep 2013 17:24:31 -0300 Subject: prevent redundant firing of InitTheFace (pFont never changes, but init is called all over the place); also some nulling and freeing to prevent leaks, and removing the redundant daddy unreffing that is done in ~FontInstance anyway (bzr r12618) --- src/libnrtype/FontInstance.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index fd0cdd3d4..38a105459 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -192,6 +192,7 @@ font_instance::~font_instance(void) //printf("font instance death\n"); if ( pFont ) { + FreeTheFace(); g_object_unref(pFont); pFont = 0; } @@ -232,10 +233,6 @@ void font_instance::Unref(void) //printf("font %x %s unref'd %i\n",this,tc,refCount); //free(tc); if ( refCount <= 0 ) { - if ( daddy ) { - daddy->UnrefFace(this); - } - daddy=NULL; delete this; } } @@ -387,6 +384,7 @@ unsigned int font_instance::Attribute(const gchar *key, gchar *str, unsigned int void font_instance::InitTheFace() { + if (theFace == NULL && pFont != NULL) { #ifdef USE_PANGO_WIN32 if ( !theFace ) { LOGFONT *lf=pango_win32_font_logfont(pFont); @@ -404,6 +402,7 @@ void font_instance::InitTheFace() FT_Select_Charmap(theFace,ft_encoding_unicode) && FT_Select_Charmap(theFace,ft_encoding_symbol); } #endif + } } void font_instance::FreeTheFace() @@ -423,6 +422,7 @@ void font_instance::InstallFace(PangoFont* iFace) return; } pFont=iFace; + iFace = NULL; InitTheFace(); -- cgit v1.2.3 From 6cc0d44d20de8e537e42dac66de344354ea80d1c Mon Sep 17 00:00:00 2001 From: buliabyak <> Date: Sat, 28 Sep 2013 17:26:16 -0300 Subject: order correction: unreffing fonts in ents needs loadedPtr so that must go before loadedPrt is nulled; this didn't crash simply because we never freed FontFactory before; also some comments and remove redundant multiply in hash function (bzr r12619) --- src/libnrtype/FontFactory.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index c896cc470..9fc553efd 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -25,7 +25,6 @@ typedef INK_UNORDERED_MAP(g_malloc(maxEnt*sizeof(font_entry)))), @@ -327,12 +326,6 @@ font_factory::font_factory(void) : font_factory::~font_factory(void) { - if (loadedPtr) { - FaceMapType* tmp = static_cast(loadedPtr); - delete tmp; - loadedPtr = 0; - } - for (int i = 0;i < nbEnt;i++) ents[i].f->Unref(); if ( ents ) g_free(ents); @@ -344,6 +337,12 @@ font_factory::~font_factory(void) #endif //g_object_unref(fontContext); + if (loadedPtr) { + FaceMapType* tmp = static_cast(loadedPtr); + delete tmp; + loadedPtr = 0; + } + // Delete the pango font pointers in the string to instance map PangoStringToDescrMap::iterator it = fontInstanceMap.begin(); while (it != fontInstanceMap.end()) { @@ -1126,7 +1125,7 @@ void font_factory::AddInCache(font_instance *who) return; } who->Ref(); - if ( nbEnt == maxEnt ) { + if ( nbEnt == maxEnt ) { // cache is filled, unref the oldest-accessed font in it int bi = 0; double ba = ents[bi].age; for (int i = 1;i < nbEnt;i++) { -- cgit v1.2.3 From 6b8c701e9d74cff5c0b2eaa2b678d8e9f7410658 Mon Sep 17 00:00:00 2001 From: buliabyak <> Date: Sat, 28 Sep 2013 17:27:10 -0300 Subject: FontInstances were being leaked here by overreffing - every call to Face must unref when done (bzr r12620) --- src/libnrtype/Layout-TNG-Compute.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/libnrtype/Layout-TNG-Compute.cpp b/src/libnrtype/Layout-TNG-Compute.cpp index 7ea089c93..973db0165 100644 --- a/src/libnrtype/Layout-TNG-Compute.cpp +++ b/src/libnrtype/Layout-TNG-Compute.cpp @@ -980,6 +980,7 @@ void Layout::Calculator::_buildPangoItemizationForPara(ParagraphInfo *para) con attribute_font_description->end_index = para_text.bytes(); pango_attr_list_insert(attributes_list, attribute_font_description); // ownership of attribute is assumed by the list + font->Unref(); } } -- cgit v1.2.3 From 0c99cd46125045a7e94ae26985e47e1104860b4a Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sat, 28 Sep 2013 18:43:28 -0400 Subject: use geometric bbox to calculate filter effect region (Bug 1229971) Fixed bugs: - https://launchpad.net/bugs/1229971 (bzr r12621) --- src/sp-item.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 89e995b5f..c342bfd9b 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -725,7 +725,7 @@ Geom::OptRect SPItem::visualBounds(Geom::Affine const &transform) const // call the subclass method // CPPIFY //bbox = this->bbox(Geom::identity(), SPItem::VISUAL_BBOX); - bbox = const_cast(this)->bbox(Geom::identity(), SPItem::VISUAL_BBOX); + bbox = const_cast(this)->bbox(Geom::identity(), SPItem::GEOMETRIC_BBOX); // see LP Bug 1229971 SPFilter *filter = SP_FILTER(style->getFilter()); // default filer area per the SVG spec: -- cgit v1.2.3 From 447cf211335e4d902b10b77a8e4c5f9f9bb3690c Mon Sep 17 00:00:00 2001 From: buliabyak <> Date: Sat, 28 Sep 2013 20:57:17 -0300 Subject: memleak fix (bzr r12622) --- src/proj_pt.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/proj_pt.cpp b/src/proj_pt.cpp index d9d4e06f1..28286948d 100644 --- a/src/proj_pt.cpp +++ b/src/proj_pt.cpp @@ -34,6 +34,7 @@ Pt2::Pt2(const gchar *coord_str) { pt[0] = g_ascii_strtod(coords[0], NULL); pt[1] = g_ascii_strtod(coords[1], NULL); pt[2] = g_ascii_strtod(coords[2], NULL); + g_strfreev (coords); } void -- cgit v1.2.3 From bf4e68d81307463eea90914566f6d6611688bb04 Mon Sep 17 00:00:00 2001 From: buliabyak <> Date: Sat, 28 Sep 2013 20:58:11 -0300 Subject: clear paints on delete to release reffed paintservers, fixes leaking of gradients (bzr r12623) --- src/display/nr-style.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/display/nr-style.cpp b/src/display/nr-style.cpp index cd7e9575f..317f38635 100644 --- a/src/display/nr-style.cpp +++ b/src/display/nr-style.cpp @@ -77,6 +77,8 @@ NRStyle::~NRStyle() if (dash){ delete [] dash; } + fill.clear(); + stroke.clear(); } void NRStyle::set(SPStyle *style) -- cgit v1.2.3 From 1e82781408cc335ca29946a4de10349d868d65be Mon Sep 17 00:00:00 2001 From: buliabyak <> Date: Sat, 28 Sep 2013 20:58:48 -0300 Subject: fix leaking of transforms (bzr r12624) --- src/display/drawing-group.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/display/drawing-group.cpp b/src/display/drawing-group.cpp index 6d52b89fc..b5ce18891 100644 --- a/src/display/drawing-group.cpp +++ b/src/display/drawing-group.cpp @@ -28,6 +28,7 @@ DrawingGroup::~DrawingGroup() { if (_style) sp_style_unref(_style); + delete _child_transform; // delete NULL; is safe } /** -- cgit v1.2.3 From ee8f0667f84689466f68eecfb9498e7b092e168b Mon Sep 17 00:00:00 2001 From: buliabyak <> Date: Sat, 28 Sep 2013 23:09:39 -0300 Subject: collectOrphans moved to the end of destructor to prevent leaking of uncollected stuff (bzr r12625) --- src/document.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index dda072283..b94b72bda 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -139,8 +139,6 @@ SPDocument::SPDocument() : } SPDocument::~SPDocument() { - collectOrphans(); - // kill/unhook this first if ( profileManager ) { delete profileManager; @@ -224,6 +222,9 @@ SPDocument::~SPDocument() { delete this->current_persp3d_impl; this->current_persp3d_impl = NULL; + // This is at the end of the destructor, because preceding code adds new orphans to the queue + collectOrphans(); + //delete this->_whiteboard_session_manager; } -- cgit v1.2.3 From 421bdee0ed2b55d175459c898240b54762119569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Sun, 29 Sep 2013 08:35:21 -0300 Subject: Adding tutorial-tracing-pixelart (bzr r12626) --- src/menus-skeleton.h | 1 + src/verbs.cpp | 5 +++++ src/verbs.h | 1 + 3 files changed, 7 insertions(+) (limited to 'src') diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index 2334a08c1..3fcb77207 100644 --- a/src/menus-skeleton.h +++ b/src/menus-skeleton.h @@ -285,6 +285,7 @@ static char const menus_skeleton[] = " \n" " \n" " \n" +" \n" " \n" " \n" " \n" diff --git a/src/verbs.cpp b/src/verbs.cpp index 23a560423..bdef0526a 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -2119,6 +2119,9 @@ void TutorialVerb::perform(SPAction *action, void *data) // TRANSLATORS: See "tutorial-basic.svg" comment. sp_help_open_tutorial(NULL, (gpointer)_("tutorial-tracing.svg")); break; + case SP_VERB_TUTORIAL_TRACING_PIXELART: + sp_help_open_tutorial(NULL, (gpointer)_("tutorial-tracing-pixelart.svg")); + break; case SP_VERB_TUTORIAL_CALLIGRAPHY: // TRANSLATORS: See "tutorial-basic.svg" comment. sp_help_open_tutorial(NULL, (gpointer)_("tutorial-calligraphy.svg")); @@ -2883,6 +2886,8 @@ Verb *Verb::_base_verbs[] = { // TRANSLATORS: "to trace" means "to convert a bitmap to vector graphics" (to vectorize) new TutorialVerb(SP_VERB_TUTORIAL_TRACING, "TutorialsTracing", N_("Inkscape: T_racing"), N_("Using bitmap tracing"), NULL/*"tutorial_tracing"*/), + new TutorialVerb(SP_VERB_TUTORIAL_TRACING_PIXELART, "TutorialsTracingPixelArt", N_("Inkscape: Tracing Pixel Art"), + N_("Using Trace Pixel Art dialog"), NULL), new TutorialVerb(SP_VERB_TUTORIAL_CALLIGRAPHY, "TutorialsCalligraphy", N_("Inkscape: _Calligraphy"), N_("Using the Calligraphy pen tool"), NULL), new TutorialVerb(SP_VERB_TUTORIAL_INTERPOLATE, "TutorialsInterpolate", N_("Inkscape: _Interpolate"), diff --git a/src/verbs.h b/src/verbs.h index 40292745a..0f764eb29 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -304,6 +304,7 @@ enum { SP_VERB_TUTORIAL_SHAPES, SP_VERB_TUTORIAL_ADVANCED, SP_VERB_TUTORIAL_TRACING, + SP_VERB_TUTORIAL_TRACING_PIXELART, SP_VERB_TUTORIAL_CALLIGRAPHY, SP_VERB_TUTORIAL_INTERPOLATE, SP_VERB_TUTORIAL_DESIGN, -- cgit v1.2.3 From 48536172f551d67942217c6d78a7f37e79c68110 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Mon, 30 Sep 2013 00:17:20 +0200 Subject: Further changes to SPEllipse. (bzr r12629) --- src/object-edit.cpp | 50 ++++++++++++++++++-------------------- src/sp-ellipse.cpp | 70 ++++++++++++++++++++--------------------------------- src/sp-ellipse.h | 16 +++++++++--- 3 files changed, 63 insertions(+), 73 deletions(-) (limited to 'src') diff --git a/src/object-edit.cpp b/src/object-edit.cpp index 5ade37cb1..28786bf66 100644 --- a/src/object-edit.cpp +++ b/src/object-edit.cpp @@ -785,24 +785,23 @@ sp_genericellipse_side(SPGenericEllipse *ellipse, Geom::Point const &p) void ArcKnotHolderEntityStart::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - int snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12); + int snaps = Inkscape::Preferences::get()->getInt("/options/rotationsnapsperpi/value", 12); - SPGenericEllipse *ge = SP_GENERICELLIPSE(item); SPArc *arc = SP_ARC(item); - ge->closed = (sp_genericellipse_side(ge, p) == -1) ? TRUE : FALSE; + arc->setClosed(sp_genericellipse_side(arc, p) == -1); - Geom::Point delta = p - Geom::Point(ge->cx.computed, ge->cy.computed); - Geom::Scale sc(ge->rx.computed, ge->ry.computed); - ge->start = atan2(delta * sc.inverse()); - if ( ( state & GDK_CONTROL_MASK ) - && snaps ) - { - ge->start = sp_round(ge->start, M_PI/snaps); + Geom::Point delta = p - Geom::Point(arc->cx.computed, arc->cy.computed); + Geom::Scale sc(arc->rx.computed, arc->ry.computed); + + arc->start = atan2(delta * sc.inverse()); + + if ((state & GDK_CONTROL_MASK) && snaps) { + arc->start = sp_round(arc->start, M_PI / snaps); } - ge->normalize(); - (static_cast(arc))->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + + arc->normalize(); + arc->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } Geom::Point @@ -828,24 +827,23 @@ ArcKnotHolderEntityStart::knot_click(guint state) void ArcKnotHolderEntityEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - int snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12); + int snaps = Inkscape::Preferences::get()->getInt("/options/rotationsnapsperpi/value", 12); - SPGenericEllipse *ge = SP_GENERICELLIPSE(item); SPArc *arc = SP_ARC(item); - ge->closed = (sp_genericellipse_side(ge, p) == -1) ? TRUE : FALSE; + arc->setClosed(sp_genericellipse_side(arc, p) == -1); - Geom::Point delta = p - Geom::Point(ge->cx.computed, ge->cy.computed); - Geom::Scale sc(ge->rx.computed, ge->ry.computed); - ge->end = atan2(delta * sc.inverse()); - if ( ( state & GDK_CONTROL_MASK ) - && snaps ) - { - ge->end = sp_round(ge->end, M_PI/snaps); + Geom::Point delta = p - Geom::Point(arc->cx.computed, arc->cy.computed); + Geom::Scale sc(arc->rx.computed, arc->ry.computed); + + arc->end = atan2(delta * sc.inverse()); + + if ((state & GDK_CONTROL_MASK) && snaps) { + arc->end = sp_round(arc->end, M_PI/snaps); } - ge->normalize(); - (static_cast(arc))->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + + arc->normalize(); + arc->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } Geom::Point diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index bc6aa1c87..80e57afc3 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -34,9 +34,6 @@ #include "preferences.h" #include "snap-candidate.h" -#define noELLIPSE_VERBOSE - - #include "sp-factory.h" namespace { @@ -69,9 +66,9 @@ bool arc_registered = SPFactory::instance().registerObject("arc", create_arc); SPGenericEllipse::SPGenericEllipse() : SPShape() - , closed(true) , start(0) , end(SP_2PI) + , _closed(true) { } @@ -79,6 +76,14 @@ SPGenericEllipse::~SPGenericEllipse() { } +bool SPGenericEllipse::closed() { + return _closed; +} + +void SPGenericEllipse::setClosed(bool value) { + _closed = value; +} + void SPGenericEllipse::update(SPCtx *ctx, guint flags) { if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { @@ -122,18 +127,11 @@ void SPGenericEllipse::update_patheffect(bool write) bool SPGenericEllipse::_isSlice() const { - // figure out if we have a slice, guarding against rounding errors - double diff = fmod(this->end - this->start, SP_2PI); - - if (diff < 0.0) { - diff += SP_2PI; - } + Geom::AngleInterval a(this->start, this->end, true); - return (fabs(diff) >= 1e-8 && fabs(diff - SP_2PI) >= 1e-8); + return !(Geom::are_near(a.extent(), 0) || Geom::are_near(a.extent(), SP_2PI)); } -/* fixme: Think (Lauris) */ -/* Can't we use arcto in this method? */ void SPGenericEllipse::set_shape() { if (hasBrokenPathEffect()) { @@ -150,11 +148,7 @@ void SPGenericEllipse::set_shape() return; } - if ((this->rx.computed < 1e-18) || (this->ry.computed < 1e-18)) { - return; - } - - if (fabs(this->end - this->start) < 1e-9) { + if (Geom::are_near(this->rx.computed, 0) || Geom::are_near(this->ry.computed, 0)) { return; } @@ -181,7 +175,7 @@ void SPGenericEllipse::set_shape() Geom::PathBuilder pb; pb.append(path); - if (this->closed) { + if (this->_closed) { // "pizza slice" pb.lineTo(center); pb.closePath(); @@ -233,10 +227,8 @@ void SPGenericEllipse::snappoints(std::vector &p, // Snap to the 4 quadrant points of the ellipse, but only if the arc // spans far enough to include them if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_ELLIPSE_QUADRANT_POINT)) { - double angle = 0; - - for (angle = 0; angle < SP_2PI; angle += M_PI_2) { - if (angle >= this->start && angle <= this->end) { + for (double angle = 0; angle < SP_2PI; angle += M_PI_2) { + if (Geom::AngleInterval(this->start, this->end, true).contains(angle)) { Geom::Point pt = this->getPointAtAngle(angle) * i2dt; p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_ELLIPSE_QUADRANT_POINT, Inkscape::SNAPTARGET_ELLIPSE_QUADRANT_POINT)); } @@ -249,7 +241,7 @@ void SPGenericEllipse::snappoints(std::vector &p, bool slice = this->_isSlice(); // Add the centre, if we have a closed slice or when explicitly asked for - if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP) && slice && this->closed) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP) && slice && this->_closed) { Geom::Point pt = Geom::Point(cx, cy) * i2dt; p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); } @@ -262,13 +254,13 @@ void SPGenericEllipse::snappoints(std::vector &p, // And if we have a slice, also snap to the endpoints if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP) && slice) { // Add the start point, if it's not coincident with a quadrant point - if (fmod(this->start, M_PI_2) != 0.0) { + if (!Geom::are_near(std::fmod(this->start, M_PI_2), 0)) { Geom::Point pt = this->getPointAtAngle(this->start) * i2dt; p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); } // Add the end point, if it's not coincident with a quadrant point - if (fmod(this->end, M_PI_2) != 0.0) { + if (!Geom::are_near(std::fmod(this->end, M_PI_2), 0)) { Geom::Point pt = this->getPointAtAngle(this->end) * i2dt; p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); } @@ -333,20 +325,10 @@ Geom::Affine SPGenericEllipse::set_transform(Geom::Affine const &xform) void SPGenericEllipse::normalize() { - this->start = fmod(this->start, SP_2PI); - this->end = fmod(this->end, SP_2PI); - - if (this->start < 0.0) { - this->start += SP_2PI; - } - - double diff = this->start - this->end; - - if (diff >= 0.0) { - this->end += diff - fmod(diff, SP_2PI) + SP_2PI; - } + Geom::AngleInterval a(this->start, this->end, true); - /* Now we keep: 0 <= start < end <= 2*PI */ + this->start = a.initialAngle().radians0(); + this->end = a.finalAngle().radians0(); } Inkscape::XML::Node *SPGenericEllipse::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) @@ -574,7 +556,7 @@ bool SPArc::sp_arc_set_elliptical_path_attribute(Inkscape::XML::Node *repr) str.arcTo(rx, ry, 0, fa, fs, p2); - if (this->closed) { + if (this->_closed) { Geom::Point center = Geom::Point(this->cx.computed, this->cy.computed); str.lineTo(center).closePath(); } @@ -603,7 +585,7 @@ Inkscape::XML::Node *SPArc::write(Inkscape::XML::Document *xml_doc, Inkscape::XM sp_repr_set_svg_double(repr, "sodipodi:start", this->start); sp_repr_set_svg_double(repr, "sodipodi:end", this->end); - repr->setAttribute("sodipodi:open", (!this->closed) ? "true" : NULL); + repr->setAttribute("sodipodi:open", (!this->_closed) ? "true" : NULL); } else { repr->setAttribute("sodipodi:end", NULL); repr->setAttribute("sodipodi:start", NULL); @@ -669,7 +651,7 @@ void SPArc::set(unsigned int key, gchar const *value) break; case SP_ATTR_SODIPODI_OPEN: - this->closed = (!value); + this->_closed = (!value); this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; @@ -691,7 +673,7 @@ void SPArc::modified(guint flags) const char *SPArc::displayName() { if (this->_isSlice()) { - if (this->closed) { + if (this->_closed) { return _("Segment"); } else { return _("Arc"); @@ -719,7 +701,7 @@ void SPArc::sp_arc_position_set(gdouble x, gdouble y, gdouble rx, gdouble ry) this->end = Geom::Angle::from_degrees(prefs->getDouble("/tools/shapes/arc/end", 0.0)).radians0(); } - this->closed = !prefs->getBool("/tools/shapes/arc/open"); + this->_closed = !prefs->getBool("/tools/shapes/arc/open"); this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } diff --git a/src/sp-ellipse.h b/src/sp-ellipse.h index d817b5511..eab0b4907 100644 --- a/src/sp-ellipse.h +++ b/src/sp-ellipse.h @@ -31,8 +31,11 @@ public: SVGLength rx; SVGLength ry; - // Stores whether the shape is closed ("pizza slice" or full ellipse) or not (arc only). - bool closed; + /** + * If we have a slice, returns whether the shape is closed ("pizza slice") or not (arc only). + */ + bool closed(); + void setClosed(bool value); double start, end; @@ -45,13 +48,20 @@ public: virtual void update_patheffect(bool write); + /** + * @brief Makes sure that start and end lie between 0 and 2 * PI. + */ void normalize(); Geom::Point getPointAtAngle(double arg) const; protected: - /// Determines whether the shape is a part of a ellipse. + /** + * @brief Determines whether the shape is a part of an ellipse. + */ bool _isSlice() const; + + bool _closed; }; -- cgit v1.2.3 From df16775103cd981612d363bd6937cd2d68801b5f Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Mon, 30 Sep 2013 04:43:12 -0400 Subject: Reduce tools-switcher code, add description for node and select toos. (bzr r12630) --- src/tools-switch.cpp | 164 ++++++++++----------------------------------------- 1 file changed, 30 insertions(+), 134 deletions(-) (limited to 'src') diff --git a/src/tools-switch.cpp b/src/tools-switch.cpp index fd160e518..32fab9f7e 100644 --- a/src/tools-switch.cpp +++ b/src/tools-switch.cpp @@ -86,6 +86,31 @@ static char const *const tool_names[] = { "/tools/lpetool", NULL }; +static char const *const tool_msg[] = { + NULL, + _("Click to Select and Tranform objects, Drag to select many objects."), + _("Modify selected path points (nodes) directly."), + _("To tweak a path by pushing, select it and drag over it."), + _("Drag, click or click and scroll to spray the selected objects."), + _("Drag to create a rectangle. Drag controls to round corners and resize. Click to select."), + _("Drag to create a 3D box. Drag controls to resize in perspective. Click to select (with Ctrl+Alt for single faces)."), + _("Drag to create an ellipse. Drag controls to make an arc or segment. Click to select."), + _("Drag to create a star. Drag controls to edit the star shape. Click to select."), + _("Drag to create a spiral. Drag controls to edit the spiral shape. Click to select."), + _("Drag to create a freehand line. Shift appends to selected path, Alt activates sketch mode."), + _("Click or click and drag to start a path; with Shift to append to selected path. Ctrl+click to create single dots (straight line modes only)."), + _("Drag to draw a calligraphic stroke; with Ctrl to track a guide path. Arrow keys adjust width (left/right) and angle (up/down)."), + _("Click to select or create text, drag to create flowed text; then type."), + _("Drag or double click to create a gradient on selected objects, drag handles to adjust gradients."), + _("Drag or double click to create a mesh on selected objects, drag handles to adjust meshes."), + _("Click or drag around an area to zoom in, Shift+click to zoom out."), + _("Drag to measure the dimensions of objects."), + _("Click to set fill, Shift+click to set stroke; drag to average color in area; with Alt to pick inverse color; Ctrl+C to copy the color under mouse to clipboard"), + _("Click and drag between shapes to create a connector."), + _("Click to paint a bounded area, Shift+click to union the new fill with the current selection, Ctrl+click to change the clicked object's fill and stroke to the current setting."), + _("Drag to erase."), + _("Choose a subtool from the toolbar"), +}; static int tools_prefpath2num(char const *id) @@ -123,140 +148,11 @@ tools_switch(SPDesktop *dt, int num) } dt->set_event_context2(tool_names[num]); - - switch (num) { - case TOOLS_SELECT: - //dt->set_event_context(SP_TYPE_SELECT_CONTEXT, tool_names[num]); - /* fixme: This is really ugly hack. We should bind and unbind class methods */ - dt->activate_guides(true); - inkscape_eventcontext_set(dt->getEventContext()); - break; - case TOOLS_NODES: - //dt->set_event_context(INK_TYPE_NODE_TOOL, tool_names[num]); - dt->activate_guides(true); - inkscape_eventcontext_set(dt->getEventContext()); - break; - case TOOLS_TWEAK: - //dt->set_event_context(SP_TYPE_TWEAK_CONTEXT, tool_names[num]); - dt->activate_guides(true); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("To tweak a path by pushing, select it and drag over it.")); - break; - case TOOLS_SPRAY: - //dt->set_event_context(SP_TYPE_SPRAY_CONTEXT, tool_names[num]); - dt->activate_guides(true); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag, click or click and scroll to spray the selected objects.")); - break; - case TOOLS_SHAPES_RECT: - //dt->set_event_context(SP_TYPE_RECT_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag to create a rectangle. Drag controls to round corners and resize. Click to select.")); - break; - case TOOLS_SHAPES_3DBOX: - //dt->set_event_context(SP_TYPE_BOX3D_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag to create a 3D box. Drag controls to resize in perspective. Click to select (with Ctrl+Alt for single faces).")); - break; - case TOOLS_SHAPES_ARC: - //dt->set_event_context(SP_TYPE_ARC_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag to create an ellipse. Drag controls to make an arc or segment. Click to select.")); - break; - case TOOLS_SHAPES_STAR: - //dt->set_event_context(SP_TYPE_STAR_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag to create a star. Drag controls to edit the star shape. Click to select.")); - break; - case TOOLS_SHAPES_SPIRAL: - //dt->set_event_context(SP_TYPE_SPIRAL_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag to create a spiral. Drag controls to edit the spiral shape. Click to select.")); - break; - case TOOLS_FREEHAND_PENCIL: - //dt->set_event_context(SP_TYPE_PENCIL_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag to create a freehand line. Shift appends to selected path, Alt activates sketch mode.")); - break; - case TOOLS_FREEHAND_PEN: - //dt->set_event_context(SP_TYPE_PEN_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Click or click and drag to start a path; with Shift to append to selected path. Ctrl+click to create single dots (straight line modes only).")); - break; - case TOOLS_CALLIGRAPHIC: - //dt->set_event_context(SP_TYPE_DYNA_DRAW_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag to draw a calligraphic stroke; with Ctrl to track a guide path. Arrow keys adjust width (left/right) and angle (up/down).")); - break; - case TOOLS_TEXT: - //dt->set_event_context(SP_TYPE_TEXT_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Click to select or create text, drag to create flowed text; then type.")); - break; - case TOOLS_GRADIENT: - //dt->set_event_context(SP_TYPE_GRADIENT_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag or double click to create a gradient on selected objects, drag handles to adjust gradients.")); - break; - case TOOLS_MESH: - //dt->set_event_context(SP_TYPE_MESH_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag or double click to create a mesh on selected objects, drag handles to adjust meshes.")); - break; - case TOOLS_ZOOM: - //dt->set_event_context(SP_TYPE_ZOOM_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Click or drag around an area to zoom in, Shift+click to zoom out.")); - break; - case TOOLS_MEASURE: - //dt->set_event_context(SP_TYPE_MEASURE_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag to measure the dimensions of objects.")); - break; - case TOOLS_DROPPER: - //dt->set_event_context(SP_TYPE_DROPPER_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Click to set fill, Shift+click to set stroke; drag to average color in area; with Alt to pick inverse color; Ctrl+C to copy the color under mouse to clipboard")); - break; - case TOOLS_CONNECTOR: - //dt->set_event_context(SP_TYPE_CONNECTOR_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Click and drag between shapes to create a connector.")); - break; - case TOOLS_PAINTBUCKET: - //dt->set_event_context(SP_TYPE_FLOOD_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Click to paint a bounded area, Shift+click to union the new fill with the current selection, Ctrl+click to change the clicked object's fill and stroke to the current setting.")); - break; - case TOOLS_ERASER: - //dt->set_event_context(SP_TYPE_ERASER_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag to erase.")); - break; - case TOOLS_LPETOOL: - //dt->set_event_context(SP_TYPE_LPETOOL_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Choose a subtool from the toolbar")); - break; - } + /* fixme: This is really ugly hack. We should bind and unbind class methods */ + /* First 4 tools use guides, first is undefined but we don't care */ + dt->activate_guides(num < 5); + inkscape_eventcontext_set(dt->getEventContext()); + dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, tool_msg[num] ); } void tools_switch_by_item(SPDesktop *dt, SPItem *item, Geom::Point const p) -- cgit v1.2.3