Bug 979199 - DataStore should not dispatch events when the window is destroyed, r=ehsan

This commit is contained in:
Andrea Marchesini 2014-03-04 16:24:32 +00:00
parent ac46e15a6e
commit 7c00b37a8f
2 changed files with 10 additions and 0 deletions

View File

@ -79,6 +79,7 @@ this.DataStore.prototype = {
_revisionId: null,
_exposedObject: null,
_cursor: null,
_shuttingdown: false,
init: function(aWindow, aName, aOwner, aReadOnly) {
debug("DataStore init");
@ -96,6 +97,8 @@ this.DataStore.prototype = {
let wId = aSubject.QueryInterface(Ci.nsISupportsPRUint64).data;
if (wId == self._innerWindowID) {
cpmm.removeMessageListener("DataStore:Changed:Return:OK", self);
cpmm.sendAsyncMessage("DataStore:UnregisterForMessages");
self._shuttingdown = true;
self._db.close();
}
}, "inner-window-destroyed", false);
@ -320,6 +323,11 @@ this.DataStore.prototype = {
this.retrieveRevisionId(
function() {
// If the window has been destroyed we don't emit the events.
if (self._shuttingdown) {
return;
}
// If we have an active cursor we don't emit events.
if (self._cursor) {
return;

View File

@ -25,6 +25,7 @@ XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
this.DataStoreChangeNotifier = {
children: [],
messages: [ "DataStore:Changed", "DataStore:RegisterForMessages",
"DataStore:UnregisterForMessages",
"child-process-shutdown" ],
init: function() {
@ -94,6 +95,7 @@ this.DataStoreChangeNotifier = {
break;
case "child-process-shutdown":
case "DataStore:UnregisterForMessages":
debug("Unregister");
for (let i = 0; i < this.children.length;) {