Bug 791910 - Deal with dead managers in our list. r=cjones
authorBlake Kaplan <mrbkap@gmail.com>
Tue, 18 Sep 2012 16:50:53 -0700
changeset 107662 ff173f01271596b70cdbafe68e5f935328f6f076
parent 107661 8c813f40ea4edb31135712f80c5a574f6a456889
child 107663 6c85aa92f4abc466790c728997d435cc5c7cab8f
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewerscjones
bugs791910
milestone18.0a1
Bug 791910 - Deal with dead managers in our list. r=cjones
dom/wifi/WifiWorker.js
--- a/dom/wifi/WifiWorker.js
+++ b/dom/wifi/WifiWorker.js
@@ -1943,18 +1943,25 @@ WifiWorker.prototype = {
       }
     }
   },
 
   // nsIWifi
 
   _domManagers: [],
   _fireEvent: function(message, data) {
-    this._domManagers.forEach(function(obj) {
-      obj.manager.sendAsyncMessage("WifiManager:" + message, data);
+    // TODO (bug 791911): Managers don't correctly tell us when they're getting
+    // destroyed, so prune dead managers here.
+    this._domManagers = this._domManagers.filter(function(obj) {
+      try {
+        obj.manager.sendAsyncMessage("WifiManager:" + message, data);
+        return true;
+      } catch(e) {
+        return false;
+      }
     });
   },
 
   _sendMessage: function(message, success, data, msg) {
     msg.manager.sendAsyncMessage(message + (success ? ":OK" : ":NO"),
                                  { data: data, rid: msg.rid, mid: msg.mid });
   },