Bug 89434 - [Mac] -[WebPDFView _menuItemsFromPDFKitForEvent:] leaks NSMenuItems
Summary: [Mac] -[WebPDFView _menuItemsFromPDFKitForEvent:] leaks NSMenuItems
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Andy Estes
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-18 23:40 PDT by Andy Estes
Modified: 2012-06-19 10:10 PDT (History)
1 user (show)

See Also:


Attachments
Patch (3.13 KB, patch)
2012-06-18 23:42 PDT, Andy Estes
darin: review+
aestes: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andy Estes 2012-06-18 23:40:23 PDT
[Mac] -[WebPDFView _menuItemsFromPDFKitForEvent:] leaks NSMenuItems
Comment 1 Andy Estes 2012-06-18 23:42:30 PDT
Created attachment 148263 [details]
Patch
Comment 2 Mark Rowe (bdash) 2012-06-19 00:05:09 PDT
Comment on attachment 148263 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=148263&action=review

> Source/WebKit/mac/WebView/WebPDFView.mm:1153
> +        RetainPtr<NSMenuItem> itemCopy(AdoptNS, [item copy]);
> +        [copiedItems addObject:itemCopy.get()];

The RetainPtr seems overkill. You can just immediately release itemCopy after adding it to the copiedItems array, and rely on the items presence in the array to keep it alive for as long as we are dealing with it.
Comment 3 Darin Adler 2012-06-19 08:30:22 PDT
Comment on attachment 148263 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=148263&action=review

>> Source/WebKit/mac/WebView/WebPDFView.mm:1153
>> +        [copiedItems addObject:itemCopy.get()];
> 
> The RetainPtr seems overkill. You can just immediately release itemCopy after adding it to the copiedItems array, and rely on the items presence in the array to keep it alive for as long as we are dealing with it.

I like Mark’s suggestion, but this change is also OK as is.
Comment 4 Andy Estes 2012-06-19 10:09:40 PDT
Committed r120726: <http://trac.webkit.org/changeset/120726>