Title: [274176] trunk/Source/WebKit
Revision
274176
Author
[email protected]
Date
2021-03-09 14:25:14 -0800 (Tue, 09 Mar 2021)

Log Message

Crash under WebViewImpl::flagsChanged()
https://bugs.webkit.org/show_bug.cgi?id=222989

Reviewed by Tim Horton.

Capture a WeakPtr for |this| in the lambda passed to interpretKeyEvent() and make sure |this|
is still alive before getting m_page. This is the same pattern that is used for other
interpretKeyEvent() calls in this file (but this one was missed).

* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::flagsChanged):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (274175 => 274176)


--- trunk/Source/WebKit/ChangeLog	2021-03-09 22:17:26 UTC (rev 274175)
+++ trunk/Source/WebKit/ChangeLog	2021-03-09 22:25:14 UTC (rev 274176)
@@ -1,5 +1,19 @@
 2021-03-09  Chris Dumez  <[email protected]>
 
+        Crash under WebViewImpl::flagsChanged()
+        https://bugs.webkit.org/show_bug.cgi?id=222989
+
+        Reviewed by Tim Horton.
+
+        Capture a WeakPtr for |this| in the lambda passed to interpretKeyEvent() and make sure |this|
+        is still alive before getting m_page. This is the same pattern that is used for other
+        interpretKeyEvent() calls in this file (but this one was missed).
+
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::flagsChanged):
+
+2021-03-09  Chris Dumez  <[email protected]>
+
         Stop using callOnMainThread() / isMainThread() in WebKit2
         https://bugs.webkit.org/show_bug.cgi?id=222986
 

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (274175 => 274176)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2021-03-09 22:17:26 UTC (rev 274175)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2021-03-09 22:25:14 UTC (rev 274176)
@@ -5289,8 +5289,9 @@
     if (eventKeyCodeIsZeroOrNumLockOrFn(event))
         return;
 
-    interpretKeyEvent(event, ^(BOOL handledByInputMethod, const Vector<WebCore::KeypressCommand>& commands) {
-        m_page->handleKeyboardEvent(NativeWebKeyboardEvent(event, handledByInputMethod, false, commands));
+    interpretKeyEvent(event, [weakThis = makeWeakPtr(*this), capturedEvent = retainPtr(event)](BOOL handledByInputMethod, const Vector<WebCore::KeypressCommand>& commands) {
+        if (weakThis)
+            weakThis->m_page->handleKeyboardEvent(NativeWebKeyboardEvent(capturedEvent.get(), handledByInputMethod, false, commands));
     });
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to