From 685ca91c9f6142ddee5b5da0c0ab77cf64459c7f Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 23 Oct 2010 22:24:27 +0200 Subject: Don't try displaying markers for completely empty paths, fixes crash. Fixed bugs: - https://launchpad.net/bugs/511577 (bzr r9843) --- src/sp-shape.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/sp-shape.cpp') diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index b64ad45e0..4d765af99 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -410,7 +410,9 @@ sp_shape_update_marker_view (SPShape *shape, NRArenaItem *ai) // position arguments to sp_marker_show_instance, basically counts the amount of markers. int counter[4] = {0}; + if (!shape->curve) return; Geom::PathVector const & pathv = shape->curve->get_pathvector(); + if (pathv.empty()) return; // the first vertex should get a start marker, the last an end marker, and all the others a mid marker // see bug 456148 @@ -585,7 +587,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const & } // Union with bboxes of the markers, if any - if (sp_shape_has_markers (shape)) { + if (sp_shape_has_markers (shape) && !shape->curve->get_pathvector().empty()) { /** \todo make code prettier! */ Geom::PathVector const & pathv = shape->curve->get_pathvector(); // START marker @@ -767,6 +769,9 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) if (!shape->curve) return; + Geom::PathVector const & pathv = shape->curve->get_pathvector(); + if (pathv.empty()) return; + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gint add_comments = prefs->getBool("/printing/debug/add-label-comments"); if (add_comments) { @@ -788,15 +793,14 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) SPStyle* style = SP_OBJECT_STYLE (item); if (!style->fill.isNone()) { - sp_print_fill (ctx, shape->curve->get_pathvector(), &i2d, style, &pbox, &dbox, &bbox); + sp_print_fill (ctx, pathv, &i2d, style, &pbox, &dbox, &bbox); } if (!style->stroke.isNone()) { - sp_print_stroke (ctx, shape->curve->get_pathvector(), &i2d, style, &pbox, &dbox, &bbox); + sp_print_stroke (ctx, pathv, &i2d, style, &pbox, &dbox, &bbox); } /** \todo make code prettier */ - Geom::PathVector const & pathv = shape->curve->get_pathvector(); // START marker for (int i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START if ( shape->marker[i] ) { -- cgit v1.2.3 From 5566cfd9907a25b6c2167ae81933da8656b22f20 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 23 Oct 2010 23:07:35 +0200 Subject: Beware: some 2geom functions can throw useful exceptions! fixing crash bug 614751 Fixed bugs: - https://launchpad.net/bugs/614751 (bzr r9845) --- src/sp-shape.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/sp-shape.cpp') diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 4d765af99..24790c657 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -24,6 +24,7 @@ #include <2geom/transforms.h> #include <2geom/pathvector.h> #include <2geom/path-intersection.h> +#include <2geom/exception.h> #include "helper/geom.h" #include "helper/geom-nodetype.h" @@ -1272,13 +1273,19 @@ static void sp_shape_snappoints(SPItem const *item, std::vectorgetSnapIntersectionCS()) { Geom::Crossings cs; - cs = self_crossings(*path_it); - if (cs.size() > 0) { // There might be multiple intersections... - for (Geom::Crossings::const_iterator i = cs.begin(); i != cs.end(); i++) { - Geom::Point p_ix = (*path_it).pointAt((*i).ta); - p.push_back(Inkscape::SnapCandidatePoint(p_ix * i2d, Inkscape::SNAPSOURCE_PATH_INTERSECTION, Inkscape::SNAPTARGET_PATH_INTERSECTION)); + try { + cs = self_crossings(*path_it); + if (cs.size() > 0) { // There might be multiple intersections... + for (Geom::Crossings::const_iterator i = cs.begin(); i != cs.end(); i++) { + Geom::Point p_ix = (*path_it).pointAt((*i).ta); + p.push_back(Inkscape::SnapCandidatePoint(p_ix * i2d, Inkscape::SNAPSOURCE_PATH_INTERSECTION, Inkscape::SNAPTARGET_PATH_INTERSECTION)); + } } + } catch (Geom::RangeError &e) { + // do nothing + // The exception could be Geom::InfiniteSolutions: then no snappoints should be added } + } } -- cgit v1.2.3 From 144819c918dc761641c3cb5a490205fb73194ee3 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Wed, 17 Nov 2010 13:12:56 +1100 Subject: Super duper mega (fun!) commit: replaced encoding=utf-8 with fileencoding=utf-8 in all 1074 Vim modelines. The reason for this is that (a) setting the encoding isn't nice, and (b) Vim 7.3 (with modeline enabled) disallows it and pops up an error whenever you open any file with it ("invalid modeline"). Also corrected five deviant modestrings: * src/ui/widget/dock.cpp and src/ui/widget/dock.h: missing colon at the end * src/ui/dialog/tile.cpp: removed gratuitous second colon at the end * src/helper/units-test.h: removed gratuitous space before a colon * share/extensions/export_gimp_palette.py: missing textwidth=99 That's my geekiest commit yet. (bzr r9900) --- src/sp-shape.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-shape.cpp') diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 24790c657..4bbfbc1e1 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -1300,4 +1300,4 @@ static void sp_shape_snappoints(SPItem const *item, std::vector