Complete copyWithZone for TorrentCell (#5079)

This commit is contained in:
Cœur 2023-03-02 22:31:23 +08:00 committed by GitHub
parent 848212eea1
commit 264437d6d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 8 deletions

View File

@ -37,9 +37,9 @@ static CGFloat const kImageOverlap = 1.0;
- (id)copyWithZone:(NSZone*)zone
{
id value = [super copyWithZone:zone];
[value setRepresentedObject:self.representedObject];
return value;
FilePriorityCell* copy = [super copyWithZone:zone];
[copy setRepresentedObject:self.representedObject];
return copy;
}
- (void)setSelected:(BOOL)flag forSegment:(NSInteger)segment

View File

@ -79,8 +79,6 @@ static NSInteger const kMaxPieces = 18 * 18;
{
if ((self = [super init]))
{
_fDefaults = NSUserDefaults.standardUserDefaults;
NSMutableParagraphStyle* paragraphStyle = [NSParagraphStyle.defaultParagraphStyle mutableCopy];
paragraphStyle.lineBreakMode = NSLineBreakByTruncatingMiddle;
@ -101,9 +99,19 @@ static NSInteger const kMaxPieces = 18 * 18;
- (id)copyWithZone:(NSZone*)zone
{
id value = [super copyWithZone:zone];
[value setRepresentedObject:self.representedObject];
return value;
TorrentCell* copy = [super copyWithZone:zone];
copy->_fTitleAttributes = [_fTitleAttributes mutableCopyWithZone:zone];
copy->_fStatusAttributes = [_fStatusAttributes mutableCopyWithZone:zone];
copy->_fBluePieceColor = _fBluePieceColor;
copy->_fBarBorderColor = _fBarBorderColor;
copy->_fBarMinimalBorderColor = _fBarMinimalBorderColor;
[copy setRepresentedObject:self.representedObject];
return copy;
}
- (NSUserDefaults*)fDefaults
{
return NSUserDefaults.standardUserDefaults;
}
- (NSRect)iconRectForBounds:(NSRect)bounds