зеркало из https://github.com/mozilla/gecko-dev.git
Bug 618188 followup - Do not remove observer twice. r=zpao
This commit is contained in:
Родитель
c513bc937e
Коммит
0b4b023267
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче