Bug 618188 followup - Do not remove observer twice. r=zpao

This commit is contained in:
Hiroyuki Ikezoe 2011-05-20 10:12:07 -07:00
Родитель c513bc937e
Коммит 0b4b023267
1 изменённых файлов: 10 добавлений и 6 удалений

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

@ -130,22 +130,26 @@ function waitForSaveState(aSaveStateCallback) {
let sessionSaveTimeout = 1000 + let sessionSaveTimeout = 1000 +
Services.prefs.getIntPref("browser.sessionstore.interval"); Services.prefs.getIntPref("browser.sessionstore.interval");
let timeout = setTimeout(function () { function removeObserver() {
if (!observing)
return;
Services.obs.removeObserver(observer, topic, false); Services.obs.removeObserver(observer, topic, false);
observing = false;
}
let timeout = setTimeout(function () {
removeObserver();
aSaveStateCallback(); aSaveStateCallback();
}, sessionSaveTimeout); }, sessionSaveTimeout);
function observer(aSubject, aTopic, aData) { function observer(aSubject, aTopic, aData) {
Services.obs.removeObserver(observer, topic, false); removeObserver();
timeout = clearTimeout(timeout); timeout = clearTimeout(timeout);
observing = false;
executeSoon(aSaveStateCallback); executeSoon(aSaveStateCallback);
} }
registerCleanupFunction(function() { registerCleanupFunction(function() {
if (observing) { removeObserver();
Services.obs.removeObserver(observer, topic, false);
}
if (timeout) { if (timeout) {
clearTimeout(timeout); clearTimeout(timeout);
} }