Sven Neumann <[EMAIL PROTECTED]> writes:

> Hi,
> I've just tried this with GIMP 2.2-pre2 from the Script-Fu console and
> you are right that the reference handling is somewhat confusing.
> Perhaps gimp_displays_reconnect() should hand the reference over to
> the display just as gimp_display_new() does. That would however mean
> that if you reconnected the display again your image would be gone
> since the last reference on it just got dropped.
> So I think the current behaviour is coorect but should perhaps be
> documented better. Your plug-in will have to call gimp_image_delete()
> on the new image in order to drop the reference it holds on it.
> Here's the example you gave:
>   gint newImage = gimp_file_load (...);
>   gimp_displays_reconnect (oldImage, newImage);
>   gimp_image_delete (oldImage);
> That last line is wrong since you never owned a reference on that
> image and it is already gone at that point. It should read instead:
>   gint newImage = gimp_file_load (...);
>   gimp_displays_reconnect (oldImage, newImage);
>   gimp_image_delete (newImage);

I tend to disagree.

IMHO we should change the PDB wrapper to

(1) work as documented (fail if the new image already has a display).
(2) also fail if the old image has no display.
(3) make it take over the reference count on success.

It's impossible to call gimp_image_delete() on an image which has
a display, so both above pieces of code won't work. and in
fact this is impossible to get right with the current
implementation of gimp_displays_reconnect().

Gimp-developer mailing list

Reply via email to