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

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

 



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);


Sven

[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