[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.platform] Re: SelectionAction.dispose

Hello Paul

Thanks for the detailed reply. Yes, I am creating the ImageDescriptor from an Image using the createFromImage(Image img) function. img changes in my code depending on what the user selects on the screen. So basically I am dynamically creating/changing the imagedescriptor when the code is run.
MyAction inherits from SelectionAction which inturn extends WorkbenchPartAction. WorkbenchPartAction has a dispose() method. The javadoc for this method says "Disposes the action when it is no longer needed.". I am overriding the dispose() function in MyAction to manually dispose off the img that I use to create the image desriptor.
This dispose() method is not being called at all in my program.


Thanks for your help.

Upkar.

Paul Webster wrote:

Upkar Lidder wrote:
Hello,

I did not find a jface group and so posting here.

This is the correct group.

I have an action (MyAction.java) that inherits from SelectionAction. MyAction uses dynamic images to set the imageDescriptor of the action. I am disposing off this image in the dispose method as follows:

Are you creating an ImageDescriptor from an Image? Or just providing multiple ImageDescriptors to you action?

Normally, IActions don't have that kind of lifecycle (i.e. actions aren't disposed). When added to menus or toolbars, the ActionContributionItem asks for the Image from the ImageDescriptor, and the ActionContributionItem is disposed with the Manager. Certain specific kinds of actions can have dispose methods, like IWorkbenchAction, but they depend on specific parts of the code (like the WorkbenchWindow or ContributionManager) to dispose them.

Later,
PW