GNOME Bugzilla – Bug 601891
gimp_image_get_selection returns None. It should always return a valid ID.
Last modified: 2009-11-14 17:32:12 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
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.
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(-)
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