cefclient: macOS: Fix CefBrowser leak during OSR shutdown (issue #2151)

This commit is contained in:
Marshall Greenblatt 2017-04-26 15:05:12 -04:00
parent f2b988a0ce
commit f440f850ef
3 changed files with 16 additions and 3 deletions

View File

@ -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<CefBrowser>)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_;

View File

@ -66,6 +66,7 @@
@property(nonatomic) BOOL handlingKeyDown;
- (id)initWithBrowser:(CefRefPtr<CefBrowser>)browser;
- (void)detach;
- (void)HandleKeyEventBeforeTextInputClient:(NSEvent*)keyEvent;
- (void)HandleKeyEventAfterTextInputClient:(CefKeyEvent)keyEvent;
- (void)ChangeCompositionRange:(CefRange)range

View File

@ -69,6 +69,10 @@ extern NSString* NSTextInputReplacementRangeAttributeName;
return self;
}
- (void)detach {
browser_ = NULL;
}
- (NSArray*)validAttributesForMarkedText {
if (!validAttributesForMarkedText_) {
validAttributesForMarkedText_ = [[NSArray alloc] initWithObjects: