Title: [258061] trunk/Source/WebKitLegacy/mac
- Revision
- 258061
- Author
- [email protected]
- Date
- 2020-03-06 21:46:09 -0800 (Fri, 06 Mar 2020)
Log Message
Flaky Test: editing/spelling/spellcheck-async.html
https://bugs.webkit.org/show_bug.cgi?id=160571
Reviewed by Ryosuke Niwa.
Second try to fix this crash; the WebEditorClient can go away before all the NSSpellChecker
callbacks are done (which happens off the main thread), so store a WeakPtr<WebEditorClient>.
We have to create the WeakPtr on the main thread, and it gets copied into the first block.
* WebCoreSupport/WebEditorClient.mm:
(-[WebEditorSpellCheckResponder initWithClient:sequence:results:]):
(-[WebEditorSpellCheckResponder perform]):
(WebEditorClient::requestCheckingOfString):
Modified Paths
Diff
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (258060 => 258061)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2020-03-07 05:32:14 UTC (rev 258060)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2020-03-07 05:46:09 UTC (rev 258061)
@@ -3,6 +3,22 @@
Flaky Test: editing/spelling/spellcheck-async.html
https://bugs.webkit.org/show_bug.cgi?id=160571
+ Reviewed by Ryosuke Niwa.
+
+ Second try to fix this crash; the WebEditorClient can go away before all the NSSpellChecker
+ callbacks are done (which happens off the main thread), so store a WeakPtr<WebEditorClient>.
+ We have to create the WeakPtr on the main thread, and it gets copied into the first block.
+
+ * WebCoreSupport/WebEditorClient.mm:
+ (-[WebEditorSpellCheckResponder initWithClient:sequence:results:]):
+ (-[WebEditorSpellCheckResponder perform]):
+ (WebEditorClient::requestCheckingOfString):
+
+2020-03-06 Simon Fraser <[email protected]>
+
+ Flaky Test: editing/spelling/spellcheck-async.html
+ https://bugs.webkit.org/show_bug.cgi?id=160571
+
Reviewed by Tim Horton.
The old code called -performSelector:target:... with an autoreleased target,
Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm (258060 => 258061)
--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm 2020-03-07 05:32:14 UTC (rev 258060)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm 2020-03-07 05:46:09 UTC (rev 258061)
@@ -1211,16 +1211,16 @@
@interface WebEditorSpellCheckResponder : NSObject
{
- WebEditorClient* _client;
+ WeakPtr<WebEditorClient> _client;
int _sequence;
RetainPtr<NSArray> _results;
}
-- (id)initWithClient:(WebEditorClient*)client sequence:(int)sequence results:(NSArray*)results;
+- (id)initWithClient:(WeakPtr<WebEditorClient>)client sequence:(int)sequence results:(NSArray*)results;
- (void)perform;
@end
@implementation WebEditorSpellCheckResponder
-- (id)initWithClient:(WebEditorClient*)client sequence:(int)sequence results:(NSArray*)results
+- (id)initWithClient:(WeakPtr<WebEditorClient>)client sequence:(int)sequence results:(NSArray*)results
{
self = [super init];
if (!self)
@@ -1233,7 +1233,8 @@
- (void)perform
{
- _client->didCheckSucceed(_sequence, _results.get());
+ if (_client)
+ _client->didCheckSucceed(_sequence, _results.get());
}
@end
@@ -1256,9 +1257,10 @@
int sequence = m_textCheckingRequest->data().sequence();
NSRange range = NSMakeRange(0, m_textCheckingRequest->data().text().length());
NSRunLoop* currentLoop = [NSRunLoop currentRunLoop];
+ WeakPtr<WebEditorClient> weakThis = makeWeakPtr(*this);
NSDictionary *options = @{ NSTextCheckingInsertionPointKey : [NSNumber numberWithUnsignedInteger:insertionPointFromCurrentSelection(currentSelection)] };
[[NSSpellChecker sharedSpellChecker] requestCheckingOfString:m_textCheckingRequest->data().text() range:range types:NSTextCheckingAllSystemTypes options:options inSpellDocumentWithTag:0 completionHandler:^(NSInteger, NSArray* results, NSOrthography*, NSInteger) {
- RetainPtr<WebEditorSpellCheckResponder> responder = adoptNS([[WebEditorSpellCheckResponder alloc] initWithClient:this sequence:sequence results:results]);
+ RetainPtr<WebEditorSpellCheckResponder> responder = adoptNS([[WebEditorSpellCheckResponder alloc] initWithClient:weakThis sequence:sequence results:results]);
[currentLoop performBlock:^{
[responder perform];
}];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes