summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-21 22:27:03 +0000
committersky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-21 22:27:03 +0000
commitc7eeed7fa25e06ec3d0367a74d2b43671958c5d3 (patch)
treeaf26d3ccfc414147ff1a0663f71723ac9faefe3d
parent1d8f8b403b0db8dee851b215918abab27e5346f9 (diff)
downloadchromium_src-c7eeed7fa25e06ec3d0367a74d2b43671958c5d3.zip
chromium_src-c7eeed7fa25e06ec3d0367a74d2b43671958c5d3.tar.gz
chromium_src-c7eeed7fa25e06ec3d0367a74d2b43671958c5d3.tar.bz2
Attempt 2 at this fix. I hit after my patch. The problem appears to be
that it is possible for browser list to return a browser with no window/tabs. This is possible depending upon timing of these. I'm moving the checks into the session service. BUG=4666 TEST=no direct way to test this as its rather random. But make sure you don't encounter any problems with session restore. Review URL: http://codereview.chromium.org/11362 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5855 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser.cc5
-rw-r--r--chrome/browser/session_service.cc9
2 files changed, 8 insertions, 6 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 262bc44..375f566 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -324,11 +324,6 @@ bool Browser::ShouldSaveWindowPlacement() const {
}
void Browser::SaveWindowPlacement(const gfx::Rect& bounds, bool maximized) {
- if (!window_) {
- // It is possible for this to be invoked during construction of the window,
- // in which case window_ is NULL.
- return;
- }
// Save to the session storage service, used when reloading a past session.
// Note that we don't want to be the ones who cause lazy initialization of
// the session service. This function gets called during initial window
diff --git a/chrome/browser/session_service.cc b/chrome/browser/session_service.cc
index f5e042e..fa11168 100644
--- a/chrome/browser/session_service.cc
+++ b/chrome/browser/session_service.cc
@@ -1119,7 +1119,14 @@ void SessionService::BuildCommandsFromBrowsers(
DCHECK(commands);
for (BrowserList::const_iterator i = BrowserList::begin();
i != BrowserList::end(); ++i) {
- if (should_track_changes_for_browser_type((*i)->type())) {
+ // Make sure the browser has tabs and a window. Browsers destructor
+ // removes itself from the BrowserList. When a browser is closed the
+ // destructor is not necessarily run immediately. This means its possible
+ // for us to get a handle to a browser that is about to be removed. If
+ // the tab count is 0 or the window is NULL, the browser is about to be
+ // deleted, so we ignore it.
+ if (should_track_changes_for_browser_type((*i)->type()) &&
+ (*i)->tab_count() && (*i)->window()) {
BuildCommandsForBrowser(*i, commands, tab_to_available_range,
windows_to_track);
}