Community
Participate
Working Groups
In case we have API that takes a resource, we should check if the resource is disposed and throw the corresponding exception as stated in the javadoc. Currently we don't care about this case. Here is a (I hope full list) of APIs we need to care about: CTabFolder#setSelectionBackground CTabItem#setFont Control#setBackground Control#setBackgroundImage Control#setCursor Control#setFont Control#setForeground TableItem#setBackground TableItem#setBackground(int,Color) TableItem#setFont TableItem#setFont(int,Font) TableItem#setForeground TableItem#setForeground(int,Color) TreeItem#setBackground TreeItem#setBackground(int,Color) TreeItem#setFont TreeItem#setFont(int,Font) TreeItem#setForeground TreeItem#setForeground(int,Color)
A question about the Control#setBackgroundImage(Image image) method: The method needs an Image object. The images that i get via Graphics.getImage() are not disposable because they are created with a factory. Is it possible to append a small Image file to the Unit Test for this method to create a disposed image? Or is there another way to create an Image object and dispose it afterwards? The Constructor Image(Device, Image, boolean) won't work with an Image got via Graphics.getImage() as an argument.
Have a look at Image_Test#testDispose(). In this test case, a disposable image is created.
Created attachment 152938 [details] First draft I implemented that the methods above throw an IllegalArgumentException (SWT.ERROR_INVALID_ARGUMTENT) if the argument is disposed. I also added this behaviour in the following methods: TreeItem#setImage(...) TableItem#setImage(...) Item#setImage(...) As i got the hint to look for a disposable Image, i added InputStream.close() to the method Image#testDispose() and all further test methods that require an InputStream object to create an Image. The IllegalArgumentException is missing in all classes that override Item#setImage(Image), so i left a comment in CTabItem#setImage(...) which doesnt't have any Javadoc comment.
(In reply to comment #3) > [ ... ] > The IllegalArgumentException is missing in all classes that override > Item#setImage(Image), so i left a comment in CTabItem#setImage(...) which > doesnt't have any Javadoc comment. I don't see a problem there, since all mentioned methods call super.setImage()
Applied patch to CVS HEAD