From cdf01e8d287e4253ead163afc9d69d38f1556699 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Thu, 21 May 2009 19:52:03 +0000 Subject: Fix crash reported in bug 214186 (related to the "remove overlap" function in the align dialog) (bzr r7913) --- src/removeoverlap/removeoverlap.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/removeoverlap/removeoverlap.cpp') 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); -- cgit v1.2.3