Community
Participate
Working Groups
Build Identifier: 20100218-1602 calling the following method of org.eclipse.ui.forms.widgets.ImageHyperLink : public void setImage(Image image) creates a disabledImage (a grey version of the original image). This disabled image is not disposed or treated properly. Therefore, using the "setImage" many times triggers an overload of handles. Reproducible: Always Steps to Reproduce: 1.Simply use the ImageHyperLink.setImage method 10000 times ...
(In reply to comment #0) > Build Identifier: 20100218-1602 > > calling the following method of org.eclipse.ui.forms.widgets.ImageHyperLink : > > public void setImage(Image image) > > creates a disabledImage (a grey version of the original image). This disabled > image is not disposed or treated properly. The code seems otherwise. public void setImage(Image image) { this.image = image; if (disabledImage != null) disabledImage.dispose(); if (image != null && !image.isDisposed()) disabledImage = new Image(image.getDevice(), image, SWT.IMAGE_DISABLE); if (image == null) { disabledImage = null; } }
My problem seem to occur because I have many ImageHyperLinks. Everytime I call setImage, the condition (image != null && !image.isDisposed()) is true, thus a new image is created : if (image != null && !image.isDisposed()) disabledImage = new Image(image.getDevice(), image, SWT.IMAGE_DISABLE); Is there any way to set an image without creating this new Image ?
the code in ImageHyperLink is right IMO. note that before creating the new disabled image the old one is disabled. the other place the disabled image needs to be disposed is when the control is disabled.
Hi you are right the dispose mechanism works correctly. The problem in our context is that we have several views containing severals image hyperlinks. For some usage the number of hyperlinks can be huge and the number of system handle too. I think, just a setter to disable the disabled icon could be enough.
> I think, just a setter to disable the disabled icon could be enough. That wouldn't be a good API. A better solution is to only create the disabledImage lazily in paintHyperlink(..) the first time it is really used (. Would be great if you could attach a patch for this.
I intend to submit the patch within 2 weeks.
New Gerrit change created: https://git.eclipse.org/r/42238
Gerrit change https://git.eclipse.org/r/42238 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=6caa7b47ae99426e6272ac2aeb50c9e42d7a62be
Thanks Tomasz!