diff options
author | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-10 21:18:03 +0000 |
---|---|---|
committer | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-10 21:18:03 +0000 |
commit | 9e43ee4061beb03ab170520b6b511025b8eaf236 (patch) | |
tree | fde04088071f2d696f90928874470cf07055b3ab /chrome/browser/cocoa/hung_renderer_controller.mm | |
parent | e8c20ffc89d4194aa290206d95f6fdf19b4d12ea (diff) | |
download | chromium_src-9e43ee4061beb03ab170520b6b511025b8eaf236.zip chromium_src-9e43ee4061beb03ab170520b6b511025b8eaf236.tar.gz chromium_src-9e43ee4061beb03ab170520b6b511025b8eaf236.tar.bz2 |
[Mac] Attempt to fix ref-after-free problems with NSTableView dataSource.
Clearing dataSource in the source's -dealloc seems generally good.
HungRendererController having a local copy of the titles is in case
the table view is redrawn as part of closing the window (this can
happen if the window is closed while the user is mousing on the
table, and perhaps at other times).
BUG=29558
TEST=Crash noted in bug stops happening.
Review URL: http://codereview.chromium.org/469016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34281 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/hung_renderer_controller.mm')
-rw-r--r-- | chrome/browser/cocoa/hung_renderer_controller.mm | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/chrome/browser/cocoa/hung_renderer_controller.mm b/chrome/browser/cocoa/hung_renderer_controller.mm index 3679747..853c96b 100644 --- a/chrome/browser/cocoa/hung_renderer_controller.mm +++ b/chrome/browser/cocoa/hung_renderer_controller.mm @@ -43,6 +43,7 @@ HungRendererController* g_instance = NULL; - (void)dealloc { DCHECK(!g_instance); + [tableView_ setDataSource:nil]; [super dealloc]; } @@ -90,19 +91,14 @@ HungRendererController* g_instance = NULL; [self close]; } -- (int)numberOfRowsInTableView:(NSTableView *)aTableView { - return hungRenderers_.size(); +- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView { + return [hungTitles_ count]; } - (id)tableView:(NSTableView*)aTableView objectValueForTableColumn:(NSTableColumn*)column - row:(int)rowIndex { - // TODO(rohitrao): Add favicons. - TabContents* contents = hungRenderers_[rowIndex]; - string16 title = contents->GetTitle(); - if (!title.empty()) - return base::SysUTF16ToNSString(title); - return l10n_util::GetNSStringWithFixup(IDS_TAB_UNTITLED_TITLE); + row:(NSInteger)rowIndex { + return [hungTitles_ objectAtIndex:rowIndex]; } - (void)windowWillClose:(NSNotification*)notification { @@ -118,11 +114,20 @@ HungRendererController* g_instance = NULL; - (void)showForTabContents:(TabContents*)contents { DCHECK(contents); hungContents_ = contents; - hungRenderers_.clear(); + scoped_nsobject<NSMutableArray> titles([[NSMutableArray alloc] init]); for (TabContentsIterator it; !it.done(); ++it) { - if (it->process() == hungContents_->process()) - hungRenderers_.push_back(*it); + if (it->process() == hungContents_->process()) { + // TODO(rohitrao): Add favicons. + const string16 title = (*it)->GetTitle(); + if (title.empty()) { + [titles addObject: + l10n_util::GetNSStringWithFixup(IDS_TAB_UNTITLED_TITLE)]; + } else { + [titles addObject:base::SysUTF16ToNSString(title)]; + } + } } + hungTitles_.reset([titles copy]); [tableView_ reloadData]; [[self window] center]; @@ -168,4 +173,3 @@ void HideForTabContents(TabContents* contents) { } } // namespace hung_renderer_dialog - |