Bug 1069605 - Only send messages in SettingsLocks when window is live; r=bent
authorKyle Machulis <kyle@nonpolynomial.com>
Thu, 18 Sep 2014 17:23:00 -0700
changeset 206106 ba79aa341f3424cc69fb6b6ff39c2cd869ad3d9e
parent 206105 b7088613e4c71839f088c4705e54efa12f2f9bba
child 206107 674e62d19031dfb8ce6fa10c19978e22ed51a7bc
push id27512
push usercbook@mozilla.com
push dateFri, 19 Sep 2014 12:07:02 +0000
treeherdermozilla-central@c8dee1c9cc3d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs1069605
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1069605 - Only send messages in SettingsLocks when window is live; r=bent
dom/settings/SettingsManager.js
--- a/dom/settings/SettingsManager.js
+++ b/dom/settings/SettingsManager.js
@@ -81,16 +81,24 @@ SettingsLock.prototype = {
   },
 
   get closed() {
     return !this._open;
   },
 
   _closeHelper: function() {
     if (DEBUG) debug("closing lock " + this._id);
+    // sendMessage can get queued to run later in a thread via
+    // _closeHelper, but the SettingsManager may have died in between
+    // the time it was scheduled and the time it runs. Make sure our
+    // window is valid before sending, otherwise just ignore.
+    if (!this._settingsManager._window) {
+      if (DEBUG) debug("SettingsManager died, cannot send " + aMessageName + " message window principal.");
+      return;
+    }
     this._open = false;
     this._closeCalled = false;
     if (!this._requests || Object.keys(this._requests).length == 0) {
       if (DEBUG) debug("Requests exhausted, finalizing " + this._id);
       this._settingsManager.unregisterLock(this._id);
       this.sendMessage("Settings:Finalize", {lockID: this._id});
     } else {
       if (DEBUG) debug("Requests left: " + Object.keys(this._requests).length);