summaryrefslogtreecommitdiffstats
path: root/src/removeoverlap/removeoverlap.cpp
diff options
context:
space:
mode:
authorDiederik van Lierop <mail@diedenrezi.nl>2009-05-21 19:52:03 +0000
committerdvlierop2 <dvlierop2@users.sourceforge.net>2009-05-21 19:52:03 +0000
commitcdf01e8d287e4253ead163afc9d69d38f1556699 (patch)
treef28964e8c1f28af028fbb51dde8fe0a3e036438f /src/removeoverlap/removeoverlap.cpp
parentadding Aurelio Heckert (diff)
downloadinkscape-cdf01e8d287e4253ead163afc9d69d38f1556699.tar.gz
inkscape-cdf01e8d287e4253ead163afc9d69d38f1556699.zip
Fix crash reported in bug 214186 (related to the "remove overlap" function in the align dialog)
(bzr r7913)
Diffstat (limited to 'src/removeoverlap/removeoverlap.cpp')
-rw-r--r--src/removeoverlap/removeoverlap.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/removeoverlap/removeoverlap.cpp b/src/removeoverlap/removeoverlap.cpp
index 084f95dfe..975b4becb 100644
--- a/src/removeoverlap/removeoverlap.cpp
+++ b/src/removeoverlap/removeoverlap.cpp
@@ -52,6 +52,17 @@ void removeoverlap(GSList const *const items, double const xGap, double const yG
if (item_box) {
Geom::Point min(item_box->min() - .5*gap);
Geom::Point max(item_box->max() + .5*gap);
+ // A negative gap is allowed, but will lead to problems when the gap is larger than
+ // the bounding box (in either X or Y direction, or both); min will have become max
+ // now, which cannot be handled by Rectangle() which is called below. And how will
+ // removeRectangleOverlap handle such a case?
+ // That's why we will enforce some boundaries on min and max here:
+ if (max[X] < min[X]) {
+ min[X] = max[X] = (min[X] + max[X])/2;
+ }
+ if (max[Y] < min[Y]) {
+ min[Y] = max[Y] = (min[Y] + max[Y])/2;
+ }
Rectangle *vspc_rect = new Rectangle(min[X], max[X], min[Y], max[Y]);
records.push_back(Record(*it, item_box->midpoint(), vspc_rect));
rs.push_back(vspc_rect);