summaryrefslogtreecommitdiff
path: root/ios
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2019-04-26 17:52:33 +0300
committerTor Lillqvist <tml@collabora.com>2019-04-26 18:04:10 +0300
commitf21665f2ac2514e2aab49785f09805c4f7dcca19 (patch)
treed227ee1456fc5ffa71aa0529aa419517bfeef7e9 /ios
parent71496cfdb25bee9da6a8370c8adee73248cc90fe (diff)
tdf#124981: Fix a few object leaks
The pointer to the DocumentViewController object in the Document class can be a weak property. This avoids a circular reference. When the DocumentViewController is being dismissed, remove the script message handlers and remove the view from its superview. Also, set the webView property to nil.
Diffstat (limited to 'ios')
-rw-r--r--ios/Mobile/Document.h2
-rw-r--r--ios/Mobile/DocumentViewController.mm6
2 files changed, 7 insertions, 1 deletions
diff --git a/ios/Mobile/Document.h b/ios/Mobile/Document.h
index 004bcce0b..a843dc7f1 100644
--- a/ios/Mobile/Document.h
+++ b/ios/Mobile/Document.h
@@ -20,7 +20,7 @@
int fakeClientFd;
}
-@property (strong) DocumentViewController *viewController;
+@property (weak) DocumentViewController *viewController;
- (void)send2JS:(const char*)buffer length:(int)length;
diff --git a/ios/Mobile/DocumentViewController.mm b/ios/Mobile/DocumentViewController.mm
index 1d70b2882..76e64d0d8 100644
--- a/ios/Mobile/DocumentViewController.mm
+++ b/ios/Mobile/DocumentViewController.mm
@@ -84,6 +84,12 @@
[self dismissViewControllerAnimated:YES completion:^ {
[self.document closeWithCompletionHandler:^(BOOL success){
LOG_TRC("close completion handler gets " << (success?"YES":"NO"));
+ [self.webView.configuration.userContentController removeScriptMessageHandlerForName:@"debug"];
+ [self.webView.configuration.userContentController removeScriptMessageHandlerForName:@"lool"];
+ [self.webView.configuration.userContentController removeScriptMessageHandlerForName:@"error"];
+ self.webView.configuration.userContentController = nil;
+ [self.webView removeFromSuperview];
+ self.webView = nil;
}];
}];
}