Bug 155395

Summary: [iOS] WKPreviewAction conforms to NSCopying but doesn’t override -copyWithZone:
Product: WebKit Reporter: mitz
Component: New BugsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, bdakin, mitz, sam, thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=155383
Attachments:
Description Flags
Patch
mitz: review-
Patch
none
Patch
none
Patch sam: review+

mitz
Reported 2016-03-12 12:04:50 PST
_WKPreviewAction (which should be renamed WKPreviewAction) is a subclass of UIPreviewAction, and therefore conforms to NSCopying. It needs to override -copyWithZone: so that when it’s copied, the the copy has the same identifier.
Attachments
Patch (1.28 KB, patch)
2016-03-14 13:31 PDT, Beth Dakin
mitz: review-
Patch (1.25 KB, patch)
2016-03-14 13:38 PDT, Beth Dakin
no flags
Patch (1.26 KB, patch)
2016-03-14 13:49 PDT, Beth Dakin
no flags
Patch (1.25 KB, patch)
2016-03-14 14:01 PDT, Beth Dakin
sam: review+
Radar WebKit Bug Importer
Comment 1 2016-03-14 13:30:15 PDT
Beth Dakin
Comment 2 2016-03-14 13:31:43 PDT
mitz
Comment 3 2016-03-14 13:33:58 PDT
Comment on attachment 274011 [details] Patch This makes a copy that doesn’t have the original’s title, style and handler!
Beth Dakin
Comment 4 2016-03-14 13:38:16 PDT
mitz
Comment 5 2016-03-14 13:40:31 PDT
Comment on attachment 274016 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=274016&action=review > Source/WebKit2/UIProcess/API/Cocoa/WKPreviewActionItem.mm:43 > + WKPreviewAction *action = [self copyWithZone:zone]; This looks infinitely recursive.
Beth Dakin
Comment 6 2016-03-14 13:42:40 PDT
(In reply to comment #5) > Comment on attachment 274016 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=274016&action=review > > > Source/WebKit2/UIProcess/API/Cocoa/WKPreviewActionItem.mm:43 > > + WKPreviewAction *action = [self copyWithZone:zone]; > > This looks infinitely recursive. Eep! It does.
Beth Dakin
Comment 7 2016-03-14 13:49:31 PDT
Beth Dakin
Comment 8 2016-03-14 14:01:15 PDT
Sam Weinig
Comment 9 2016-03-14 15:51:57 PDT
Comment on attachment 274024 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=274024&action=review You should remove the explicit conformance to NSCopying of WKPreviewAction since UIPreviewAction already conforms to it. > Source/WebKit2/UIProcess/API/Cocoa/WKPreviewActionItem.mm:45 > + WKPreviewAction *action = [super copyWithZone:zone]; > + action->_identifier = self.identifier; > + return action; Since WKPreviewAction is immutable, this can be implemented as: return [self retain];
Sam Weinig
Comment 10 2016-03-14 15:55:24 PDT
(In reply to comment #9) > Comment on attachment 274024 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=274024&action=review > > You should remove the explicit conformance to NSCopying of WKPreviewAction > since UIPreviewAction already conforms to it. > > > Source/WebKit2/UIProcess/API/Cocoa/WKPreviewActionItem.mm:45 > > + WKPreviewAction *action = [super copyWithZone:zone]; > > + action->_identifier = self.identifier; > > + return action; > > Since WKPreviewAction is immutable, this can be implemented as: > > return [self retain]; Actually, it looks like it isn't completely immutable, so you should do your thing.
Beth Dakin
Comment 11 2016-03-14 15:58:51 PDT
Note You need to log in before you can comment on or make changes to this bug.