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

2004-11-22 Thread David Hodson
Michael Natterer wrote:
Sven Neumann <[EMAIL PROTECTED]> writes:

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

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().
(Note: I haven't updated to 2.2pre yet, I'm still running 2.0.3.)
In fact, if I remove the gimp_image_delete(oldImage), then the old
image does not get removed when the display is reconnected.
If anyone wants to investigate further, the code is at:
http://members.ozemail.com.au/~hodsond/fileSeq.html
--
David Hodson  --  this night wounds time
___
Gimp-developer mailing list
[EMAIL PROTECTED]
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer


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

2004-11-22 Thread Michael Natterer

FYI, I opened a bug for this issue:

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


Michael Natterer <[EMAIL PROTECTED]> writes:

> 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().
>
> ciao,
> --mitch
> ___
> Gimp-developer mailing list
> [EMAIL PROTECTED]
> http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer
___
Gimp-developer mailing list
[EMAIL PROTECTED]
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer


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

2004-11-22 Thread Michael Natterer
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().

ciao,
--mitch
___
Gimp-developer mailing list
[EMAIL PROTECTED]
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer


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

2004-11-20 Thread hodsond
Sven,

> 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 think I tried that without success, but I'll update to the latest version and 
try again. Thanks.

-- David


This message was sent through MyMail http://www.mymail.com.au


___
Gimp-developer mailing list
[EMAIL PROTECTED]
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer


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

2004-11-20 Thread Sven Neumann
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
___
Gimp-developer mailing list
[EMAIL PROTECTED]
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer


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

2004-11-20 Thread Sven Neumann
Hi,

David Hodson <[EMAIL PROTECTED]> writes:

> I've got a plugin that attaches to an existing (displayed) image,
> and replaces it with a different image:
>
>gint newImage = gimp_file_load(...);
>gimp_displays_reconnect(oldImage, newImage);
>gimp_image_delete(oldImage);
>
> Problem is that (I think) the new image now has two references, so
> when the user closes the image display the image is not deleted.
> If that's right, is there any way to remove the extra reference?

If that is what happens, then that would be a bug that needs
fixing. Could you please try with GIMP 2.2-pre2? If the image still
shows up in the "Images" dialog after you closed the last display,
then please file a bug report for it.


Sven

___
Gimp-developer mailing list
[EMAIL PROTECTED]
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer


[Gimp-developer] Image reference count problem in plugin

2004-11-19 Thread David Hodson
I've got a plugin that attaches to an existing (displayed) image,
and replaces it with a different image:
  gint newImage = gimp_file_load(...);
  gimp_displays_reconnect(oldImage, newImage);
  gimp_image_delete(oldImage);
Problem is that (I think) the new image now has two references, so
when the user closes the image display the image is not deleted.
If that's right, is there any way to remove the extra reference?
If not, what's going on?
--
David Hodson  --  this night wounds time
___
Gimp-developer mailing list
[EMAIL PROTECTED]
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer