diff --git a/Blink/SmarterKeys/SmarterTermInput.swift b/Blink/SmarterKeys/SmarterTermInput.swift index 5c41982a2..5508bc795 100644 --- a/Blink/SmarterKeys/SmarterTermInput.swift +++ b/Blink/SmarterKeys/SmarterTermInput.swift @@ -60,7 +60,7 @@ class CaretHider { var isHardwareKB: Bool { kbView.traits.isHKBAttached } - var device: TermDevice? = nil { + weak var device: TermDevice? = nil { didSet { reportStateReset() } } diff --git a/Blink/TermView.m b/Blink/TermView.m index c104e130f..36f63e522 100644 --- a/Blink/TermView.m +++ b/Blink/TermView.m @@ -639,6 +639,7 @@ - (void)terminate { _device = nil; // Disconnect message handler + [_webView terminate]; [_webView.configuration.userContentController removeScriptMessageHandlerForName:@"interOp"]; } diff --git a/KB/Native/Views/KBWebViewBase.h b/KB/Native/Views/KBWebViewBase.h index da867301d..5880b2de6 100644 --- a/KB/Native/Views/KBWebViewBase.h +++ b/KB/Native/Views/KBWebViewBase.h @@ -57,6 +57,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)onOut:(NSString *)data; - (void)onIME:(NSString *)event data:(NSString *)data; - (void)setTrackingModifierFlags:(UIKeyModifierFlags)trackingModifierFlags; +- (void)terminate; - (void)_keyboardDidChangeFrame:(NSNotification *)notification; - (void)_keyboardWillChangeFrame:(NSNotification *)notification; diff --git a/KB/Native/Views/KBWebViewBase.m b/KB/Native/Views/KBWebViewBase.m index 84e270e62..a5c6d31bf 100644 --- a/KB/Native/Views/KBWebViewBase.m +++ b/KB/Native/Views/KBWebViewBase.m @@ -143,6 +143,9 @@ - (instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguratio +- (void)terminate { + [self.configuration.userContentController removeScriptMessageHandlerForName:_interopName]; +} - (void)dealloc { [NSNotificationCenter.defaultCenter removeObserver:self];