[183082] Memory leak. Should put images into image registry. Check in approved fix.
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/util/XSDCommonUIUtils.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/util/XSDCommonUIUtils.java
index 508c6df..3d1dcd5 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/util/XSDCommonUIUtils.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/util/XSDCommonUIUtils.java
@@ -22,6 +22,7 @@
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML;
import org.eclipse.wst.xsd.ui.internal.adt.design.ImageOverlayDescriptor;
+import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin;
import org.eclipse.xsd.XSDAnnotation;
import org.eclipse.xsd.XSDAttributeDeclaration;
import org.eclipse.xsd.XSDAttributeGroupDefinition;
@@ -66,8 +67,17 @@
{
if (xsdAnnotation.getApplicationInformation().size() > 0)
{
- ImageOverlayDescriptor ovr = new ImageOverlayDescriptor(baseImage, isReadOnly);
- Image newImage = ovr.getImage();
+ // Will use the class name appended by the read only state as the name of the image.
+ // There is a disabled and an enabled version of each baseImage, so we can't simply
+ // use the component name as the name of the image
+ String imageName = input.getClass().getName() + isReadOnly;
+ Image newImage = XSDEditorPlugin.getDefault().getImageRegistry().get(imageName);
+ if (newImage == null)
+ {
+ ImageOverlayDescriptor ovr = new ImageOverlayDescriptor(baseImage, isReadOnly);
+ newImage = ovr.getImage();
+ XSDEditorPlugin.getDefault().getImageRegistry().put(imageName, newImage);
+ }
return newImage;
}
}