diff --git a/tests/cefclient/browser/browser_window_osr_mac.mm b/tests/cefclient/browser/browser_window_osr_mac.mm index dc19118b8..47bf2ebd6 100644 --- a/tests/cefclient/browser/browser_window_osr_mac.mm +++ b/tests/cefclient/browser/browser_window_osr_mac.mm @@ -189,12 +189,19 @@ NSPoint ConvertPointFromWindowToScreen(NSWindow* window, NSPoint point) { name:NSWindowDidChangeBackingPropertiesNotification object:nil]; + if (text_input_context_osr_mac_) { + [GetInputClientFromContext(text_input_context_osr_mac_) release]; + [text_input_context_osr_mac_ release]; + } + [super dealloc]; } - (void)detach { renderer_ = NULL; browser_window_ = NULL; + if (text_input_context_osr_mac_) + [GetInputClientFromContext(text_input_context_osr_mac_) detach]; } - (CefRefPtr)getBrowser { @@ -527,10 +534,11 @@ NSPoint ConvertPointFromWindowToScreen(NSWindow* window, NSPoint point) { - (NSTextInputContext*)inputContext { if (!text_input_context_osr_mac_) { CefTextInputClientOSRMac* text_input_client = - [[CefTextInputClientOSRMac alloc] initWithBrowser:[self getBrowser]]; + [[[CefTextInputClientOSRMac alloc] + initWithBrowser:[self getBrowser]] retain]; - text_input_context_osr_mac_ = [[NSTextInputContext alloc] initWithClient: - text_input_client]; + text_input_context_osr_mac_ = [[[NSTextInputContext alloc] initWithClient: + text_input_client] retain]; } return text_input_context_osr_mac_; diff --git a/tests/cefclient/browser/text_input_client_osr_mac.h b/tests/cefclient/browser/text_input_client_osr_mac.h index d35b3062a..02c336220 100644 --- a/tests/cefclient/browser/text_input_client_osr_mac.h +++ b/tests/cefclient/browser/text_input_client_osr_mac.h @@ -66,6 +66,7 @@ @property(nonatomic) BOOL handlingKeyDown; - (id)initWithBrowser:(CefRefPtr)browser; +- (void)detach; - (void)HandleKeyEventBeforeTextInputClient:(NSEvent*)keyEvent; - (void)HandleKeyEventAfterTextInputClient:(CefKeyEvent)keyEvent; - (void)ChangeCompositionRange:(CefRange)range diff --git a/tests/cefclient/browser/text_input_client_osr_mac.mm b/tests/cefclient/browser/text_input_client_osr_mac.mm index 0440b7963..a1dada00f 100644 --- a/tests/cefclient/browser/text_input_client_osr_mac.mm +++ b/tests/cefclient/browser/text_input_client_osr_mac.mm @@ -69,6 +69,10 @@ extern NSString* NSTextInputReplacementRangeAttributeName; return self; } +- (void)detach { + browser_ = NULL; +} + - (NSArray*)validAttributesForMarkedText { if (!validAttributesForMarkedText_) { validAttributesForMarkedText_ = [[NSArray alloc] initWithObjects: