Bug 379512 - [Palette] PaletteEditPart should use a ResourceManager to manage images
Summary: [Palette] PaletteEditPart should use a ResourceManager to manage images
Status: NEW
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy GEF (MVC) (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: gef-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-15 05:27 EDT by Peter Severin CLA
Modified: 2012-05-15 05:28 EDT (History)
0 users

See Also:


Attachments
Added support for ResourceManager to PaletteEditPart (2.53 KB, patch)
2012-05-15 05:28 EDT, Peter Severin CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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