Skip to content

Commit

Permalink
Remove equality check when setting rippleColor to prevent crashes ste…
Browse files Browse the repository at this point in the history
…mming from CIColor (#9237)

Comparing a non-`UICIColor` (e.g., a `UIExtendedSRGBColorSpace` UIColor) with a `UICIColor` crashes with the message:

> error: -[MDCActionSheetTableCellTest testSetRippleColor] : failed: caught "NSInvalidArgumentException", "-[UICIColor colorSpaceName]: unrecognized selector sent to instance 0x7ff1c02595b0"

Because of this, and the fact that this check is likely an unnecessary optimization (and because `isEqual:` does not return YES for UIColors from different color spaces, even if they have the same RGBA values), this PR removes the equality check.

Fixes #9236
  • Loading branch information
bryanoltman committed Dec 10, 2019
1 parent d0c581e commit 30df338
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 0 additions & 4 deletions components/ActionSheet/src/MDCActionSheetController.m
Expand Up @@ -523,11 +523,7 @@ - (void)setInkColor:(UIColor *)inkColor {
}

- (void)setRippleColor:(UIColor *)rippleColor {
if (_rippleColor == rippleColor || [_rippleColor isEqual:rippleColor]) {
return;
}
_rippleColor = rippleColor;

[self.tableView reloadData];
}

Expand Down
14 changes: 14 additions & 0 deletions components/ActionSheet/tests/unit/MDCActionSheetTableCellTest.m
Expand Up @@ -148,6 +148,20 @@ - (void)testSetInkColor {
}
}

- (void)testSetRippleColor {
// When
NSArray *colors = [MDCActionSheetTestHelper colorsToTest];

for (UIColor *color in colors) {
self.actionSheet.rippleColor = color;
NSArray *cells = [MDCActionSheetTestHelper getCellsFromActionSheet:self.actionSheet];
for (MDCActionSheetItemTableViewCell *cell in cells) {
// Then
XCTAssertEqualObjects(cell.rippleColor, color);
}
}
}

- (void)testSetActionFont {
// Given
UIFont *actionFont = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
Expand Down

0 comments on commit 30df338

Please sign in to comment.