After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 567393 - Rectangle select tool size shrinks to 0 if size is larger than the image and the up or down arrow is pressed.
Rectangle select tool size shrinks to 0 if size is larger than the image and ...
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Tools
2.6.4
Other All
: Normal minor
: 2.6
Assigned To: GIMP Bugs
GIMP Bugs
: 590463 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2009-01-11 18:04 UTC by Adam Morris
Modified: 2009-08-01 16:28 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Adam Morris 2009-01-11 18:04:26 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.
Comment 1 Michael Schumacher 2009-01-12 13:01:16 UTC
Yes, I'm seeing this with GIMP 2.6.4 as well.
Comment 2 Nattapong Sirilappanich 2009-03-31 04:29:34 UTC
This bug can be observed with GIMP 2.6.6 too.
Comment 3 Massimo 2009-06-30 11:44:11 UTC
(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;
     }
 }
 



Comment 4 Sven Neumann 2009-06-30 21:21:34 UTC
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(-)
Comment 5 Martin Nordholts 2009-07-01 19:53:15 UTC
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.
Comment 6 Sven Neumann 2009-07-01 20:43:42 UTC
If the author would have given his proper name and email address, I would have done this.
Comment 7 Sven Neumann 2009-07-08 19:19:15 UTC
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.
Comment 8 Martin Nordholts 2009-08-01 16:28:09 UTC
*** Bug 590463 has been marked as a duplicate of this bug. ***