Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 462719

Summary: Incorrect "equals" method for RGBA
Product: [Eclipse Project] Platform Reporter: Ian Bull <irbull>
Component: SWTAssignee: 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    

Description Ian Bull CLA 2015-03-20 15:43:22 EDT
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);
}
Comment 1 Niraj Modi CLA 2015-03-23 06:28:38 EDT
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
Comment 2 Niraj Modi CLA 2015-04-28 04:26:15 EDT
Verified the fix in build: I20150428-0100
Comment 3 Sravan Kumar Lakkimsetti CLA 2015-04-29 02:59:08 EDT
Verified the fix in build: I20150428-0100