diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-08 16:38:19 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-08 16:38:19 +0000 |
commit | 0b33b05917d7ce24c4a7fb62c4e78b576aafd803 (patch) | |
tree | 2fc22ebaeb4c31c3b00045689d05ef6cfc3b71fa | |
parent | 53f0cd2f4a2fef445068a0b08d440e67d964c642 (diff) | |
download | chromium_src-0b33b05917d7ce24c4a7fb62c4e78b576aafd803.zip chromium_src-0b33b05917d7ce24c4a7fb62c4e78b576aafd803.tar.gz chromium_src-0b33b05917d7ce24c4a7fb62c4e78b576aafd803.tar.bz2 |
Attempt to fix crash that I don't fully understand and can't repro :(
BUG=8933
Review URL: http://codereview.chromium.org/63085
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13357 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-x | chrome/browser/autocomplete/autocomplete_popup_view_win.cc | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_win.cc b/chrome/browser/autocomplete/autocomplete_popup_view_win.cc index 9e76de3..9549389 100755 --- a/chrome/browser/autocomplete/autocomplete_popup_view_win.cc +++ b/chrome/browser/autocomplete/autocomplete_popup_view_win.cc @@ -345,7 +345,8 @@ void AutocompletePopupViewWin::OnMouseMove(UINT keys, const CPoint& point) { void AutocompletePopupViewWin::OnPaint(HDC other_dc) { const AutocompleteResult& result = model_->result(); - DCHECK(!result.empty()); // Shouldn't be drawing an empty popup. + CHECK(!result.empty()); // Shouldn't be drawing an empty popup; any empty + // result set should have synchronously closed us. CPaintDC dc(m_hWnd); @@ -365,8 +366,18 @@ void AutocompletePopupViewWin::OnPaint(HDC other_dc) { } // Only repaint the invalid lines. + // In rare cases, it seems possible to get line offsets off the end of the + // popup. I suspect this can happen when the user invalidates a new line + // (e.g. by moving the mouse) and, before the paint request is serviced, hits + // a key that causes autocomplete to run, causing the results list to become + // shorter (at least initially). So sanitize the line numbers here. + const size_t last_valid_line = result.size() - 1; const size_t first_line = PixelToLine(dc.m_ps.rcPaint.top); - const size_t last_line = PixelToLine(dc.m_ps.rcPaint.bottom); + if (first_line > last_valid_line) + return; + const size_t last_line = + std::min(PixelToLine(dc.m_ps.rcPaint.bottom), last_valid_line); + for (size_t i = first_line; i <= last_line; ++i) { DrawLineInfo::LineStatus status; // Selection should take precedence over hover. |