Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Why is the platform disposing my title image for an editor?
Why is the platform disposing my title image for an editor? [message #289415] Thu, 04 August 2005 14:24 Go to next message
Eclipse UserFriend
Originally posted by: eddie.streambase.com

In 3.0, we had an editor that called setTitleImage to toggle between two
title images at various moments. We had to Image pointers, one obtained
from getTitleImage() when it started up (thus the image as specified
from our plugin.xml extension) the other our own Image.

In 3.1, when I call setTitleImage to change it, the original image (the
"default" one) is disposed by the platform! (see
WorkbenchPart.setTitleImage(Image), calling
JFaceResources.getResources().destroyImage(imageDescriptor)) . So when I
try to put the image back again, I hit an assertion.

What's going on? Why does setTitleImage dispose of the old one? What if
I want to toggle amongst two images?

Thank you,
Eddie
Re: Why is the platform disposing my title image for an editor? [message #289436 is a reply to message #289415] Thu, 04 August 2005 18:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eddie.streambase.com

Note: this seems to be happening only on linux, not on windows -- what's
going on?

Eddie Galvez wrote:
> In 3.0, we had an editor that called setTitleImage to toggle between two
> title images at various moments. We had to Image pointers, one obtained
> from getTitleImage() when it started up (thus the image as specified
> from our plugin.xml extension) the other our own Image.
>
> In 3.1, when I call setTitleImage to change it, the original image (the
> "default" one) is disposed by the platform! (see
> WorkbenchPart.setTitleImage(Image), calling
> JFaceResources.getResources().destroyImage(imageDescriptor)) . So when I
> try to put the image back again, I hit an assertion.
>
> What's going on? Why does setTitleImage dispose of the old one? What if
> I want to toggle amongst two images?
>
> Thank you,
> Eddie
Re: Why is the platform disposing my title image for an editor? [message #289479 is a reply to message #289436] Fri, 05 August 2005 13:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ""t.s.maedert.s.maeder\"..hispeedhispeed.chch"

Eddie Galvez wrote:
> Note: this seems to be happening only on linux, not on windows -- what's
> going on?
>
> Eddie Galvez wrote:
>
>> In 3.0, we had an editor that called setTitleImage to toggle between
>> two title images at various moments. We had to Image pointers, one
>> obtained from getTitleImage() when it started up (thus the image as
>> specified from our plugin.xml extension) the other our own Image.
>>
>> In 3.1, when I call setTitleImage to change it, the original image
>> (the "default" one) is disposed by the platform! (see
>> WorkbenchPart.setTitleImage(Image), calling
>> JFaceResources.getResources().destroyImage(imageDescriptor)) . So when
>> I try to put the image back again, I hit an assertion.
>>
>> What's going on? Why does setTitleImage dispose of the old one? What
>> if I want to toggle amongst two images?
>>
>> Thank you,
>> Eddie

Hi Eddie,

the general rule is: if you create a SWT resource (such as an image),
you're responsible for disposing it. As I understand your scenario, the
editor creates the default image. If you set another one, the editor
disposes the default one, since it can't know that you have a reference.

I suppose you could make a copy like so: Image myCopy= new
Image(getDisplay(), originalImage.getImageData());

Thomas
Re: Why is the platform disposing my title image for an editor? [message #289499 is a reply to message #289479] Fri, 05 August 2005 18:23 Go to previous message
Eclipse UserFriend
Originally posted by: eddie.streambase.com

>
> Hi Eddie,
>
> the general rule is: if you create a SWT resource (such as an image),
> you're responsible for disposing it. As I understand your scenario, the
> editor creates the default image. If you set another one, the editor
> disposes the default one, since it can't know that you have a reference.
>
> I suppose you could make a copy like so: Image myCopy= new
> Image(getDisplay(), originalImage.getImageData());
>
> Thomas


Right, it looks like as you say, the editor created the default image,
and so it wants to dispose of it. I indeed created an image copy and use
that instead.

- Eddie
Previous Topic:ActionFactory.QUIT and preWindowShellClose
Next Topic:Can Plugin create a security manager?
Goto Forum:
  


Current Time: Thu Mar 28 18:19:08 GMT 2024

Powered by FUDForum. Page generated in 0.02097 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top