| Summary: | API inconsistencies between dispose() and isDisposed() | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Markus Keller <markus.kell.r> | ||||
| Component: | SWT | Assignee: | Lakshmi P Shanmugam <lshanmug> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | trivial | ||||||
| Priority: | P3 | CC: | daniel_megert, Silenio_Quarti | ||||
| Version: | 3.6 | Keywords: | Documentation | ||||
| Target Milestone: | 3.6 RC3 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
A long time ago only isDisposed() was allowed after the widget was disposed. We changed this restriction to include dispose() and forgot to update the doc of isDisposed(). dispose() is a noop after the widget is disposed. Lakshmi please update the doc. Created attachment 169666 [details]
patch
updated javadoc for dispose() and isDisposed().
Fixed in HEAD > 20100524 . |
HEAD The dispose() and isDisposed() methods of e.g. Widget and Resource have inconsistent APIs. - isDisposed() says: * When a widget/resource has been disposed, it is an error to * invoke any other method using the widget/resource. - dispose() does not state any restrictions and does not declare that it throws an exception (e.g. ERROR_WIDGET_DISPOSED). Furthermore, Widget#dispose() contains this comment: /* * Note: It is valid to attempt to dispose a widget * more than once. If this happens, fail silently. */ If the restriction in isDisposed() really applies, then this must be moved up to the class Javadoc and dispose() must declare the exception. You cannot assume that a caller of dispose() reads the Javadocs of all other methods. However, the more sensible fix is: - in isDisposed(), replace "any other method" with something like: "any other method (except {@link #dispose()})" - in dispose(), you could add a statement telling that the method does nothing when the widget/resource is already disposed This should be done for all declarations of the the two methods in SWT.