Summary: | Disposing an image changes its hashCode | ||
---|---|---|---|
Product: | [Eclipse Project] Platform | Reporter: | Michael Valenta <Michael.Valenta> |
Component: | SWT | Assignee: | Silenio Quarti <Silenio_Quarti> |
Status: | NEW --- | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | john.arthorne, markus.kell.r, sxenos, tomasz.zarna |
Version: | 3.3 | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: | |||
Bug Depends on: | |||
Bug Blocks: | 175526, 181215 |
Description
Michael Valenta
2007-08-09 13:17:10 EDT
Here's a comment John made on bug 175526: I think it would be best to fix the implementation of Image equals and hashCode. Note also that unequal instances of Image become equal to each other after the images are disposed (since both their handles become zero). This isn't technically a violation of the equals/hashCode contract, but it's nevertheless confusing and likely to lead to errors for clients. Otherwise we'll need to track down and remove any use of Image as hashtable keys. This has caused some troubles for me as well. For reference, bug 236324 shows another victim of unstable image hash code. Most subclasses of Resource have the same problem (e.g. Color, Font). A solution would be to implement isDisposed() using "device == null" and not set the handle to -1 in the implementations of destroy(). That way, the hashCode() stays stable, and the only remaining glitch is that disposed resources from different devices could be considered equal. But that's already the case today, and should rarely be an issue. This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. |