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 701594 - gimp-image-select-item does not recognize path transformations
gimp-image-select-item does not recognize path transformations
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Script-Fu
2.8.4
Other Linux
: Normal minor
: 2.8
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2013-06-04 13:59 UTC by saulgoode
Modified: 2013-06-04 15:43 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description saulgoode 2013-06-04 13:59:28 UTC
The PDB function 'gimp-image-select-item' does not respect the changes made to a path that has been transformed using 'gimp-vectors-stroke-scale', 'gimp-vectors-stroke-rotate', 'gimp-vectors-stroke-translate', et cetera. 

To verify this anomalous behavior, perform the following steps in the Script-fu console to create a new image with a square path:

(define image (car (gimp-image-new 100 100 RGB)))
(gimp-display-new image)
(define layer (car (gimp-layer-new image 100 100 0 "BG" 100 0)))
(gimp-drawable-fill layer WHITE-FILL)
(gimp-image-insert-layer image layer 0 0)
(define path (car (gimp-vectors-new image "Path")))
(gimp-image-add-vectors image path 0)
(define stroke (car (gimp-vectors-stroke-new-from-points 
                        path 
                        0 ; type bezier
                        24 ; number of coordinates
                        #(10 10 10 10 10 10 
                          20 10 20 10 20 10
                          20 20 20 20 20 20
                          10 20 10 20 10 20) 
                        TRUE )))
(gimp-item-set-visible path TRUE)
(gimp-vectors-stroke-get-points path stroke)
---END OF CODE---

At this point, everything is fine. Now let's perform some transformations on our square path:

(gimp-vectors-stroke-scale path stroke 4 4)
(gimp-vectors-stroke-get-points path stroke)
---END OF CODE---

Even though there is no update to the display, we can see that the points in the path have been properly transformed. And, as expected, further transformations will be based on the new coordinates.

(gimp-vectors-stroke-rotate path stroke 60 60 45)
(gimp-vectors-stroke-get-points path stroke)
---END OF CODE---

We can even stroke the path and it is properly painted: 

(gimp-edit-stroke-vectors layer path)
---END OF CODE---

The problem arises when we try to create a selection based upon the transformed path:

(gimp-image-select-item image CHANNEL-OP-REPLACE path)
---END OF CODE---

Our selection is not based upon the transformed points of our path, but is instead based upon the original, unscaled and non-rotated path (the one displayed in the un-updated display). I can think of no reason why this behavior should be desirable, and thus this bug report.

I have tried flushing the displays, toggling the visibility of the path, even making another path active then switching back; all to no avail. 

There is a work-around, however, that reduces this bug to being almost trivial. If we add or remove a stroke on the same path after it has been transformed, the path will be fully updated -- it will display properly if visible and selections can be properly created from it. 

The following code adds then removes a simple, one-point stroke to induce this update:

(gimp-vectors-remove-stroke 
    path 
    (car (gimp-vectors-stroke-new-from-points 
             path 0 6 #(0 0 0 0 0 0) FALSE )))
---END OF CODE---

With this work-around, there is probably little pressing need to resolve this bug. Nonetheless, it seems strange that just the one function, 'gimp-image-select-item', does not honor path transformations. More concerning than the unintuitive nature of the work-around is the thought that 'gimp-image-select-item' might be accessing memory that has been freed or only maintained within the UNDO history (which might eventually be freed. Why else would the original path points still exist in memory?

As a final note, while I have posted this under the Script-fu component, I would expect that the bug report applies equally to plugs-ins (as it is only using PDB functionality).
Comment 1 Michael Natterer 2013-06-04 14:54:08 UTC
Thanks, fixed in master and gimp-2-8:

commit 4b957cf404e0b9f636befd8cba4726d341852be2
Author: Michael Natterer <mitch@gimp.org>
Date:   Tue Jun 4 16:48:41 2013 +0200

    Bug 701594 - gimp-image-select-item does not recognize path transformations
    
    pdb: Need to gimp_vectors_freeze()/thaw() around stroke modifications
    so the vector's preview and the cached GimpBezierDesc are invalidated.
    (cherry picked from commit 64887fe06cb8558d24c92c218b759dce1183afaa)

 app/pdb/vectors-cmds.c       |   18 ++++++++++++++++++
 tools/pdbgen/pdb/vectors.pdb |   18 ++++++++++++++++++
 2 files changed, 36 insertions(+)
Comment 2 saulgoode 2013-06-04 15:43:32 UTC
Fixed in less than hour! I am duly impressed.

Wow! You actually fixed it faster than it took me to describe it.