diff options
author | finnur@google.com <finnur@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-26 00:08:35 +0000 |
---|---|---|
committer | finnur@google.com <finnur@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-26 00:08:35 +0000 |
commit | da570e8948b6584dc18f624a40a81a165d2f3de9 (patch) | |
tree | d81c356ddb1d815057f894bfcffce25f529b19d3 /chrome/browser/views/find_bar_win.cc | |
parent | 29d25005a8778783608c89015bdfbd25cadb7d3f (diff) | |
download | chromium_src-da570e8948b6584dc18f624a40a81a165d2f3de9.zip chromium_src-da570e8948b6584dc18f624a40a81a165d2f3de9.tar.gz chromium_src-da570e8948b6584dc18f624a40a81a165d2f3de9.tar.bz2 |
We can get into a state where the automation framework presses the Close button in the Find box after the tab has been destroyed. This causes the Find box to act on a NULL web_contents_ pointer.
We now guard against this by checking for NULL web_contents before performing any work that relies on it.
(I can't reproduce this bug manually or by running the automation testing locally, but this is an attempt to fix the crash by using the information gathered from looking at the crash dump).
Review URL: http://codereview.chromium.org/27173
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10414 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/find_bar_win.cc')
-rw-r--r-- | chrome/browser/views/find_bar_win.cc | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/chrome/browser/views/find_bar_win.cc b/chrome/browser/views/find_bar_win.cc index 9ab7f1d..8c4cce9 100644 --- a/chrome/browser/views/find_bar_win.cc +++ b/chrome/browser/views/find_bar_win.cc @@ -196,15 +196,19 @@ void FindBarWin::EndFindSession() { animation_->Reset(1.0); animation_->Hide(); - // When we hide the window, we need to notify the renderer that we are done - // for now, so that we can abort the scoping effort and clear all the - // tickmarks and highlighting. - web_contents_->StopFinding(false); // false = don't clear selection on - // page. - view_->UpdateForResult(web_contents_->find_result(), std::wstring()); - - // When we get dismissed we restore the focus to where it belongs. - RestoreSavedFocus(); + // |web_contents_| can be NULL for a number of reasons, for example when the + // tab is closing. We must guard against that case. See issue 8030. + if (web_contents_) { + // When we hide the window, we need to notify the renderer that we are done + // for now, so that we can abort the scoping effort and clear all the + // tickmarks and highlighting. + web_contents_->StopFinding(false); // false = don't clear selection on + // page. + view_->UpdateForResult(web_contents_->find_result(), std::wstring()); + + // When we get dismissed we restore the focus to where it belongs. + RestoreSavedFocus(); + } } void FindBarWin::ChangeWebContents(WebContents* contents) { @@ -280,8 +284,8 @@ void FindBarWin::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { if (type == NotificationType::FIND_RESULT_AVAILABLE) { - // Don't update for notifications from TabContentses other than the one we are - // actively tracking. + // Don't update for notifications from TabContentses other than the one we + // are actively tracking. if (Source<TabContents>(source).ptr() == web_contents_) { UpdateUIForFindResult(web_contents_->find_result(), web_contents_->find_text()); |