From 306a90d718ba3bf8d4a0f5f18ec30aa0e5c9432a Mon Sep 17 00:00:00 2001 From: "snej@chromium.org" Date: Tue, 26 Jan 2010 17:30:22 +0000 Subject: Fix for Mac tooltip crasher. BUG=23397 TEST=none Review URL: http://codereview.chromium.org/543200 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37110 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/cocoa/autocomplete_text_field.h | 3 +++ chrome/browser/cocoa/autocomplete_text_field.mm | 5 +++++ 2 files changed, 8 insertions(+) (limited to 'chrome') diff --git a/chrome/browser/cocoa/autocomplete_text_field.h b/chrome/browser/cocoa/autocomplete_text_field.h index 1405cb5..0f29f1e 100644 --- a/chrome/browser/cocoa/autocomplete_text_field.h +++ b/chrome/browser/cocoa/autocomplete_text_field.h @@ -88,6 +88,9 @@ class AutocompleteTextFieldObserver { // Handles being a drag-and-drop target. scoped_nsobject dropHandler_; + + // Holds current tooltip strings, to keep them from being dealloced. + scoped_nsobject currentToolTips_; } @property AutocompleteTextFieldObserver* observer; diff --git a/chrome/browser/cocoa/autocomplete_text_field.mm b/chrome/browser/cocoa/autocomplete_text_field.mm index 0697a92..6743461 100644 --- a/chrome/browser/cocoa/autocomplete_text_field.mm +++ b/chrome/browser/cocoa/autocomplete_text_field.mm @@ -26,6 +26,7 @@ - (void)awakeFromNib { DCHECK([[self cell] isKindOfClass:[AutocompleteTextFieldCell class]]); dropHandler_.reset([[URLDropTargetHandler alloc] initWithView:self]); + currentToolTips_.reset([[NSMutableArray alloc] init]); } - (void)flagsChanged:(NSEvent*)theEvent { @@ -222,6 +223,7 @@ // subviews. Unless more tooltips are added to this view, this should suffice // in place of managing a set of NSToolTipTag objects. [self removeAllToolTips]; + [currentToolTips_ removeAllObjects]; AutocompleteTextFieldCell* cell = [self autocompleteTextFieldCell]; const size_t pageActionCount = [cell pageActionCount]; @@ -231,6 +233,9 @@ if (!tooltip) continue; + // -[NSView addToolTipRect:owner:userData] does _not_ retain the owner! + // Put the string in a collection so it can't be dealloced while in use. + [currentToolTips_ addObject:tooltip]; [self addToolTipRect:iconRect owner:tooltip userData:nil]; } } -- cgit v1.1