Community
Participate
Working Groups
As a follow up to Bug 570094 I found myself creating yet another resource factory to manage "one-off" resource leaks. JFace provides ResourceManager and *Registry but that API is a) intended for long term resource caching. b) complicated Instead of setTitleImage(new Image(display, inputStream))); // resource leak Use setTitleImage(Factory.create(someControl, inputStream))); // Factory class replacing this specific Image constructor public static Image create(Control control, InputStream inputStream) { Image image = new Image(control.getDisplay(), inputStream); control.addDisposeListener(e -> image.dispose()); return image; }
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/174947
Yep, same needed for Font / Cursor / Region. May be API should use Supplier<Resource>, not just InputStream, or both. I had lot of code that created some icons / fonts manually but using higher level API, without streams.
(In reply to Andrey Loskutov from comment #2) > Yep, same needed for Font / Cursor / Region. > > May be API should use Supplier<Resource>, not just InputStream, or both. I > had lot of code that created some icons / fonts manually but using higher > level API, without streams. The inputstream is just an example of one of the constructors.
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/174948