Bug 676780 - Fennec is unable to load webpages and close tabs (corrupt sessionstore) [r=mbrubeck]

This commit is contained in:
Mark Finkle 2011-08-10 15:48:37 -04:00
Родитель 6f2de80bf9
Коммит 31e3f07272
2 изменённых файлов: 19 добавлений и 12 удалений

Просмотреть файл

@ -355,10 +355,12 @@ var Browser = {
// Initial window resizes call functions that assume a tab is in the tab list
// and restored tabs are added too late. We add a dummy to to satisfy the resize
// code and then remove the dummy after the session has been restored.
let dummy = this.addTab("about:blank");
let dummy = this.addTab("about:blank", true);
let dummyCleanup = {
observe: function() {
observe: function(aSubject, aTopic, aData) {
Services.obs.removeObserver(dummyCleanup, "sessionstore-windows-restored");
if (aData == "fail")
Browser.addTab(commandURL || Browser.getHomePage(), true);
dummy.chromeTab.ignoreUndo = true;
Browser.closeTab(dummy, { forceClose: true });
}

Просмотреть файл

@ -707,14 +707,16 @@ SessionStore.prototype = {
},
restoreLastSession: function ss_restoreLastSession(aBringToFront) {
// The previous session data has already been renamed to the backup file
if (!this._sessionFileBackup.exists())
return;
let self = this;
function notifyObservers() {
function notifyObservers(aMessage) {
self._clearCache();
Services.obs.notifyObservers(null, "sessionstore-windows-restored", "");
Services.obs.notifyObservers(null, "sessionstore-windows-restored", aMessage || "");
}
// The previous session data has already been renamed to the backup file
if (!this._sessionFileBackup.exists()) {
notifyObservers("fail")
return;
}
try {
@ -723,7 +725,7 @@ SessionStore.prototype = {
NetUtil.asyncFetch(channel, function(aStream, aResult) {
if (!Components.isSuccessCode(aResult)) {
Cu.reportError("SessionStore: Could not read from sessionstore.bak file");
notifyObservers();
notifyObservers("fail");
return;
}
@ -742,14 +744,17 @@ SessionStore.prototype = {
}
if (!data || data.windows.length == 0) {
notifyObservers();
notifyObservers("fail");
return;
}
let window = Services.wm.getMostRecentWindow("navigator:browser");
let selected = data.windows[0].selected;
let tabs = data.windows[0].tabs;
let selected = data.windows[0].selected;
if (selected > tabs.length) // Clamp the selected index if it's bogus
selected = 1;
for (let i=0; i<tabs.length; i++) {
let tabData = tabs[i];
@ -795,7 +800,7 @@ SessionStore.prototype = {
});
} catch (ex) {
Cu.reportError("SessionStore: Could not read from sessionstore.bak file: " + ex);
notifyObservers();
notifyObservers("fail");
}
}
};