| Summary: | Incorrect "equals" method for RGBA | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Ian Bull <irbull> |
| Component: | SWT | Assignee: | Niraj Modi <niraj.modi> |
| Status: | VERIFIED FIXED | QA Contact: | |
| Severity: | major | ||
| Priority: | P3 | CC: | niraj.modi, sravankumarl |
| Version: | 4.5 | ||
| Target Milestone: | 4.5 M7 | ||
| Hardware: | PC | ||
| OS: | All | ||
| Whiteboard: | |||
| Bug Depends on: | |||
| Bug Blocks: | 435384 | ||
Fixed, also added corresponding JUnits for RGBA class, refer below git patch: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=af322ae00bfa5a678cf57666253c5e4b2bfd3072 Verified the fix in build: I20150428-0100 Verified the fix in build: I20150428-0100 |
The equals method is broken in RGBA. It tests that the other object is an instance of RGB, and fast fails if it's not. It should test if it's an instance of RGBA and fast fail. Here is correct method: @Override public boolean equals(Object object) { if (object == this) return true; if (!(object instanceof RGBA)) return false; RGBA rgba = (RGBA)object; return (rgba.rgb.red == this.rgb.red) && (rgba.rgb.green == this.rgb.green) && (rgba.rgb.blue == this.rgb.blue) && (rgba.alpha == this.alpha); }