[webkit-changes] [WebKit/WebKit] d4bba7: [macOS] Memory leaks because of reference cycle cr...

Darin Adler noreply at github.com
Sat Sep 10 19:01:50 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d4bba747437a2aaf524494e364a184992b966cf9
      https://github.com/WebKit/WebKit/commit/d4bba747437a2aaf524494e364a184992b966cf9
  Author: Darin Adler <darin at apple.com>
  Date:   2022-09-10 (Sat, 10 Sep 2022)

  Changed paths:
    M Source/WebCore/editing/cocoa/DictionaryLookup.mm

  Log Message:
  -----------
  [macOS] Memory leaks because of reference cycle created by -[WebRevealHighlight setClearTextIndicator:]
https://bugs.webkit.org/show_bug.cgi?id=245003
rdar://99411435

Reviewed by Tim Horton.

* Source/WebCore/editing/cocoa/DictionaryLookup.mm:
(-[WebRevealHighlight revealContext:stopHighlightingItem:]): Use std::exchange instead
of just WTFMove to get and clear the "clear text indicator" function. Not needed to fix
the bug, but a more correct idiom, since WTFMove is not guaranteed to clear out the object
being moved from.

(WebCore::showPopupOrCreateAnimationController): Moved the null check of clearTextIndicator
outside the block. This is not needed to fix the bug, but the function can't become null
later, so it can be checked first, and when there is no function it is correct and safe to
not call setClearTextIndicator: on the newly created WebRevealHighlight object. Removed the
unnecessary capture of webHighlight. This is the bug fix. Capturing this created a reference
cycle that wouldn't be broken until the -[WebRevealHighlight revealContext:stopHighlightingItem:]
method is called, and was unnecessary.

Canonical link: https://commits.webkit.org/254359@main




More information about the webkit-changes mailing list