From 2b6e0b43dbcb38e1098a5308d36ba5e75c08d5a1 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 17 Jul 2011 14:05:05 +0200 Subject: Fix crash that occurred when scaling a clipped object, as reported in lp:811819 Fixed bugs: - https://launchpad.net/bugs/811819 (bzr r10464) --- src/sp-item-transform.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/sp-item-transform.cpp') diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index eb4b81a61..0fbce27f9 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -248,10 +248,6 @@ get_scale_transform_with_unequal_stroke (Geom::Rect const &bbox_visual, Geom::Re gdouble r0w = w0 - bbox_geom.width(); // r0w is the average strokewidth of the left and right edges, i.e. 0.5*(r0l + r0r) gdouble r0h = h0 - bbox_geom.height(); // r0h is the average strokewidth of the top and bottom edges, i.e. 0.5*(r0t + r0b) - // Check whether the stroke is not negative; should not be possible, but just in case: - g_assert(r0w >= 0); - g_assert(r0h >= 0); - if (bbox_visual.hasZeroArea()) { // Obviously we cannot scale from empty visual bounding boxes at all, so we will only translate in such a case Geom::Affine move = Geom::Translate(x0 - bbox_visual.min()[Geom::X], y0 - bbox_visual.min()[Geom::Y]); return (move); @@ -266,6 +262,14 @@ get_scale_transform_with_unequal_stroke (Geom::Rect const &bbox_visual, Geom::Re return (p2o * direct * o2n); } + // Check whether the stroke is negative; i.e. the geometric bounding box is larger than the visual bounding box, which + // occurs for example for clipped objects (see launchpad bug #811819) + if (r0w < 0 || r0w < 0) { + // How should we handle the stroke width scaling of clipped object? I don't know if we can/should handle this, + // so for now we simply return the direct scaling + return (p2o * direct * o2n); + } + // Here starts the calculation you've been waiting for; first do some preparation int flip_x = (w1 > 0) ? 1 : -1; int flip_y = (h1 > 0) ? 1 : -1; -- cgit v1.2.3