Changeset 247185 in webkit


Ignore:
Timestamp:
Jul 5, 2019 4:34:49 PM (5 years ago)
Author:
dino@apple.com
Message:

[iOS] Context Menu - Add to Reading List does nothing
https://bugs.webkit.org/show_bug.cgi?id=199504
<rdar://problem/52554137>

Reviewed by Anders Carlsson.

We were holding weak references to the _WKElementAction in
the handler provided to UIAction. By the time the handler was
called, the object had been deallocated.

  • UIProcess/API/Cocoa/_WKElementAction.mm:

(-[_WKElementAction uiActionForElementInfo:]): Use strong references in handler.

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r247180 r247185  
     12019-07-05  Dean Jackson  <dino@apple.com>
     2
     3        [iOS] Context Menu - Add to Reading List does nothing
     4        https://bugs.webkit.org/show_bug.cgi?id=199504
     5        <rdar://problem/52554137>
     6
     7        Reviewed by Anders Carlsson.
     8
     9        We were holding weak references to the _WKElementAction in
     10        the handler provided to UIAction. By the time the handler was
     11        called, the object had been deallocated.
     12
     13        * UIProcess/API/Cocoa/_WKElementAction.mm:
     14        (-[_WKElementAction uiActionForElementInfo:]): Use strong references in handler.
     15
    1162019-07-05  Ryosuke Niwa  <rniwa@webkit.org>
    217
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.mm

    r246867 r247185  
    3030
    3131#import "GestureTypes.h"
     32#import "Logging.h"
    3233#import "WKActionSheetAssistant.h"
    3334#import "WKContentViewInteraction.h"
     
    285286    UIActionIdentifier identifier = elementActionTypeToUIActionIdentifier(self.type);
    286287
    287     return [UIAction actionWithTitle:self.title image:image identifier:identifier handler:[weakSelf = WeakObjCPtr<_WKElementAction>(self), weakElementInfo = WeakObjCPtr<_WKActivatedElementInfo>(elementInfo)] (UIAction *) {
    288         auto strongSelf = weakSelf.get();
    289         if (!strongSelf)
    290             return;
    291         auto strongElementInfo = weakElementInfo.get();
    292         if (!strongElementInfo)
    293             return;
    294         [strongSelf runActionWithElementInfo:strongElementInfo.get()];
     288    return [UIAction actionWithTitle:self.title image:image identifier:identifier handler:[retainedSelf = retainPtr(self), retainedInfo = retainPtr(elementInfo)] (UIAction *) {
     289        auto elementAction = retainedSelf.get();
     290        RELEASE_LOG(ContextMenu, "Executing action for type: %s", elementActionTypeToUIActionIdentifier([elementAction type]).UTF8String);
     291        [elementAction runActionWithElementInfo:retainedInfo.get()];
    295292    }];
    296293}
Note: See TracChangeset for help on using the changeset viewer.