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 601891 - gimp_image_get_selection returns None. It should always return a valid ID.
gimp_image_get_selection returns None. It should always return a valid ID.
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Gimp-Python
2.6.6
Other Linux
: Normal normal
: 2.6
Assigned To: Manish Singh
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2009-11-14 12:49 UTC by Rene Jensen
Modified: 2009-11-14 17:32 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Rene Jensen 2009-11-14 12:49:55 UTC
OS: Arch Linux
GIMP: freshly updated Gimp (2.6.6)

Reproduce bug:
1) Create a new image
2) Make a selection (in any possible way)
3) Open the Python-Fu console
4) Enter:
import gimp
s = gimp.pdb.gimp_image_get_selection( gimp.image_list()[0] )
print s   # Prints: None

Problem:
According to the docs at http://developer.gimp.org/api/2.0/libgimp/libgimp-gimpimage.html#gimp-image-get-selection:
"Returns the specified image's selection.
This will always return a valid ID for a selection -- which is represented as a channel internally."


Fixed?
I've checked the list of bugs fixed in 2.6.7 but didn't see this one. I also searched for "gimp_image_get_selection" in Bugzilla and even "get_selection". No luck.

Thanks,
Rene
Comment 1 Sven Neumann 2009-11-14 15:33:44 UTC
Works fine in Script-Fu, so it appears that the PDB function is working correctly.

Note that the selection is an attribute of the image object in the Python bindings, so you can get to the selection using image.selection. I am not sure why you are using the PDB directly from Python, but this should nevertheless be fixed.
Comment 2 Sven Neumann 2009-11-14 15:54:03 UTC
Fixed in both branches:

commit 474b5fdff3b0bb39f252e67f7ead6357e6f69007
Author: Sven Neumann <sven@gimp.org>
Date:   Sat Nov 14 16:50:42 2009 +0100

    Bug 601891 -  gimp_image_get_selection returns None
    
    The code used to make the assumption that the selection mask was
    a layer. Actually it is a channel and changing the code accordingly
    fixes the reported problem.

 plug-ins/pygimp/pygimp-pdb.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
Comment 3 Rene Jensen 2009-11-14 17:32:12 UTC
Thanks a bunch Sven. That was fast.

It was an old Python script I had which had stopped working. Using image.selection solved it without trouble.

Regards,
Rene