GNOME Bugzilla – Bug 567393
Rectangle select tool size shrinks to 0 if size is larger than the image and the up or down arrow is pressed.
Last modified: 2009-08-01 16:28:09 UTC
Please describe the problem: When using the rectangle select tool, if you draw a select box bigger than the image, then click the up or down arrow on the toolbar to fine tune the size of one of the axes that is too large, the axis will shrink to 0 for the select box. For example (values may be different), if an image that has a size of 1024 for the x-axis, and you draw a select box with 1025 for the x-axis then click the down arrow to set it to zero to match up with the image, you get a select box that now has 0 for the x-axis. Steps to reproduce: 1. Draw a rectangular select box larger than your image. 2. On one of the axes that is larger, click the up or down arrow. 3. Watch as the select box shrinks to 0 for that axis. Actual results: The select box shrinks to a 0 for that axis. Expected results: The select box shrinks or grows by 1, allowing you to fine tune the size of the box to match with the image. Does this happen every time? Yes. Other information: GIMP installed via the Ubuntu APT Repositories.
Yes, I'm seeing this with GIMP 2.6.4 as well.
This bug can be observed with GIMP 2.6.6 too.
(In reply to comment #0) Referring to the release 2.6.6 in the file libgimpmath/gimpmath.h there is a macro #define ROUND(x) ((int) ((x) + 0.5)) supposed to round its argument to the nearest integer. But it fails for many negative numbers (ROUND(-2.) == -1). This is the cause of the bug #567393 (http://bugzilla.gnome.org/show_bug.cgi?id=567393) patching file 'app/tools/gimprectangletool.c' with the following quick and dirty hack fixes the problem. Cheers --- gimp-2.6.6/app/tools/gimprectangletool.c 2008-11-24 10:53:13.000000000 +0100 +++ app/tools/gimprectangletool.c 2009-06-29 15:09:46.000000000 +0200 @@ -4099,13 +4099,13 @@ { GimpRectangleToolPrivate *priv = GIMP_RECTANGLE_TOOL_GET_PRIVATE (rect_tool); - priv->x1_int = ROUND (priv->x1); - priv->y1_int = ROUND (priv->y1); + priv->x1_int = (int)RINT(priv->x1); + priv->y1_int = (int)RINT(priv->y1); if (gimp_rectangle_tool_rect_rubber_banding_func (rect_tool)) { - priv->width_int = ROUND (priv->x2) - priv->x1_int; - priv->height_int = ROUND (priv->y2) - priv->y1_int; + priv->width_int = (int)RINT (priv->x2) - priv->x1_int; + priv->height_int = (int)RINT (priv->y2) - priv->y1_int; } }
Well spotted. I have pushed this change together with a similar change to gimp_rectangle_tool_adjust_coord() to the master branch from where I will merge it to the gimp-2-6 branch soon unless someone objects: commit 05537763ef9f88cdfcccd03e5023b39886d4f9f7 Author: Sven Neumann <sven@gimp.org> Date: Tue Jun 30 23:19:13 2009 +0200 Bug 567393 – Rectangle select tool size shrinks to 0 if size is larger than the image and the up or down arrow is pressed. Applied patch from Massimo as found in bug #567393. This changes ROUND() to RINT() to correct rounding for negative numbers. Also did this change in gimp_rectangle_tool_adjust_coord(). app/tools/gimprectangletool.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
Please use the proper --author in the commits. The extra time it takes is saved as we don't have to go through all commit messages and look for "patch by" to properly update AUTHORS for example. We could even have automated updating of AUTHORS if we use the --author feature of git correctly.
If the author would have given his proper name and email address, I would have done this.
I've also applied this to the gimp-2-6 branch now. Will push later tonight. Closing as FIXED. Massimo, thanks for your help with this bug.
*** Bug 590463 has been marked as a duplicate of this bug. ***