summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-04 03:35:28 +0000
committersky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-04 03:35:28 +0000
commit023b66d1d8e7fcb99a6ae7dfbed1ce998d3c6882 (patch)
tree51007504c23630ac2e6bcf1eb666ab5d7504ee2e /chrome
parent771e72d11e2b5be58c5e5cf1e927921d99388590 (diff)
downloadchromium_src-023b66d1d8e7fcb99a6ae7dfbed1ce998d3c6882.zip
chromium_src-023b66d1d8e7fcb99a6ae7dfbed1ce998d3c6882.tar.gz
chromium_src-023b66d1d8e7fcb99a6ae7dfbed1ce998d3c6882.tar.bz2
Fixes crash in history view. The crash occurs with the following
sequence: 1. Delete a day of history. 2. Before the delete finishes, click to delete another day. 3. While the modal dialog is up wait for the delete/reload to complete. 4. Click ok. This crashes because the index supplied to delete in step 2 is bogus after step 3 completes. I suspect we could make this a bit more elegant, but I'm holding off until we figure out the HTML versions of these. BUG=1358107 TEST=Make sure history deletion still works. Review URL: http://codereview.chromium.org/602 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1708 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/history_model.cc14
-rw-r--r--chrome/browser/history_view.cc6
2 files changed, 20 insertions, 0 deletions
diff --git a/chrome/browser/history_model.cc b/chrome/browser/history_model.cc
index 36317c2..23d3456 100644
--- a/chrome/browser/history_model.cc
+++ b/chrome/browser/history_model.cc
@@ -182,6 +182,20 @@ void HistoryModel::Refresh() {
observer_->ModelEndWork();
search_depth_ = 0;
InitVisitRequest(search_depth_);
+
+ if (results_.size() > 0) {
+ // There are results and we've been asked to reload. If we don't swap out
+ // the results now, the view is left holding indices that are going to
+ // change as soon as the load completes, which poses problems for deletion.
+ // In particular, if the user deletes a range, then clicks on delete again
+ // a modal dialog is shown. If during the time the modal dialog is shown
+ // and the user clicks ok the load completes, the index passed to delete is
+ // no longer valid. To avoid this we empty out the results immediately.
+ history::QueryResults empty_results;
+ results_.Swap(&empty_results);
+ if (observer_)
+ observer_->ModelChanged(true);
+ }
}
void HistoryModel::Observe(NotificationType type,
diff --git a/chrome/browser/history_view.cc b/chrome/browser/history_view.cc
index 0c8043b..5add4fc 100644
--- a/chrome/browser/history_view.cc
+++ b/chrome/browser/history_view.cc
@@ -1256,6 +1256,12 @@ void HistoryView::DeleteDayAtModelIndex(int index) {
return;
}
+ if (index < 0 || index >= model_->GetItemCount()) {
+ // Bogus index.
+ NOTREACHED();
+ return;
+ }
+
UserMetrics::RecordAction(L"History_DeleteHistory", model_->profile());
// BrowsingDataRemover deletes itself when done.