[Gimp-developer] "Cancel" function and plugins

Nathan Summers rockwalrus at gmail.com
Wed Jun 7 06:19:31 PDT 2006


On 6/7/06, Toby Speight <T.M.Speight.90 at cantab.net> wrote:
> (Delurk: I'm a sporadic developer of plugins, some of which are almost
> good enough to shove in the registry, and I've watched this list for a
> few months)
>
> One of my current projects is a multifrequency blend tool (inspired
> by, but not based on, the enblend program), and as part of its
> operation, it invokes a couple of other plugins (I don't see the point
> in reinventing wheels!).
>
> One thing that's not covered in any of the "how to write a plugin"
> guides is how to poll for cancel.  Of course, the plugin could have
> its own cancel button, but then the user would have to know which
> sub-plugin is running and find the correct cancel button!  (I'm happy
> to deal with the call to the sub-plugin returning GIMP_PDB_CANCEL).
>
> So - how does a plugin poll the Gimp's cancel button?  I couldn't find
> any examples in the src/plug-ins directory...

"Cancelling" a plugin kills it unconditionally.  It's been a few
months since I looked at that code, but I'm fairly sure that there is
no way for a plug-in to catch that it's been cancelled.

You really should check the value of each pdb call you make and make
sure that the return value is GIMP_PDB_SUCCESS.  There is almost
certainly code out there that doesn't check the return value and just
assumes nothing wrong happened, but that doesn't mean it's the right
thing to do. :)

Which gives me an idea for a simple macro that causes the function to
return GIMP_EXECUTION_ERROR when given an error status, and does
nothing otherwise.

Rockwalrus


More information about the Gimp-developer mailing list