]> git.lyx.org Git - features.git/commitdiff
(Rob Lahaye): fix crash when clipping.
authorAngus Leeming <leeming@lyx.org>
Thu, 31 Oct 2002 11:14:13 +0000 (11:14 +0000)
committerAngus Leeming <leeming@lyx.org>
Thu, 31 Oct 2002 11:14:13 +0000 (11:14 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5560 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/xforms/ChangeLog
src/frontends/xforms/xformsImage.C

index 380460268b89f4c11d1b745167f1d9bf1b842a26..a9d0db9a9cb6abddcc3b0a42d5e2b1044603bf17 100644 (file)
@@ -1,3 +1,7 @@
+2002-10-31  Rob Lahaye  <lahaye@snu.ac.kr>
+
+       * xformsImage.C (clip): fix crash caused by uint -> int nastiness.
+
 2002-10-29  Rob Lahaye  <lahaye@snu.ac.kr>
 
        * FormParagraph.[Ch]:
index ff45269a31c8cd37fd65aa9334f3683428e25bd8..c9fb7d35ea29097a005fd9473b4ecb314ce44bb9 100644 (file)
@@ -280,12 +280,17 @@ void xformsImage::clip(Params const & params)
                // Bounds are unchanged.
                return;
 
-       // FIXME: these values are unsigned so this makes NO sense
-       int const xoffset_l = std::max(0U, params.bb.xl);
-       int const xoffset_r = std::max(0U, image_->w - params.bb.xr);
-       int const yoffset_t = std::max(0U, image_->h - params.bb.yt);
-       int const yoffset_b = std::max(0U, params.bb.yb);
+       // flimage.h: image_ members w and h are of type int
+       // (though always >= 0)
+       // GraphicsParams.h: params.bb members xl, xr, yt and yb are of
+       // type unsigned int.
+       // We must, therefore, be careful...
+       int const xoffset_l = params.bb.xl;
+       int const yoffset_b = params.bb.yb;
+       int const xoffset_r = image_->w > params.bb.xr ?
+               image_->w - params.bb.xr : 0;
+       int const yoffset_t = image_->h > params.bb.yt ?
+               image_->h - params.bb.yt : 0;
 
        flimage_crop(image_, xoffset_l, yoffset_t, xoffset_r, yoffset_b);
 }