Bug 379512

Summary: [Palette] PaletteEditPart should use a ResourceManager to manage images
Product: [Tools] GEF Reporter: Peter Severin <peter>
Component: GEF-Legacy GEF (MVC)Assignee: gef-inbox <gef-inbox>
Status: NEW --- QA Contact:
Severity: major    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Added support for ResourceManager to PaletteEditPart none

Description Peter Severin CLA 2012-05-15 05:27:44 EDT
Build Identifier: 

This issue is related to Bug 154145, but it's not the same. The current approach in PaletteEditPart to create images is via a static ImageCache. Images are created once and then never disposed. This is an issue in my case as the palette contents is more dynamic and can change at runtime. Since images are never disposed the application runs out of SWT resources at some point.

I think a proper solution should use a ResourceManager that is passed down into the edit part using a viewer property. If there is no ResourceManager then the code can fall back to using ImageCache. This way the host application can better control the lifecycle of images. It can choose to pre-allocate images to match current behavior or create them on demand. The ResourceManager can also be shared between multiple palettes to allow for image reuse.

I created a patch for what I have in mind. Note that when the descriptor changes, a new image is created first and old descriptor is destroyed after. This way if the descriptor is the same (equals) then the image is reused.

Reproducible: Always
Comment 1 Peter Severin CLA 2012-05-15 05:28:29 EDT
Created attachment 215623 [details]
Added support for ResourceManager to PaletteEditPart