Re: [Gimp-developer] Image reference count problem in plugin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



FYI, I opened a bug for this issue:

http://bugzilla.gnome.org/show_bug.cgi?id=159051


Michael Natterer <mitch@xxxxxxxx> writes:

> Sven Neumann <sven@xxxxxxxx> 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().
>
> ciao,
> --mitch
> _______________________________________________
> Gimp-developer mailing list
> Gimp-developer@xxxxxxxxxxxxxxxxxxxxxx
> http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer

[Index of Archives]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [GIMP for Windows]     [KDE]     [GEGL]     [Gimp's Home]     [Gimp on GUI]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux