Bug 1473513 - reduce number of poolFor calls; r=ochameau
MozReview-Commit-ID: 9VqKPauAP9j
--- a/devtools/shared/protocol.js
+++ b/devtools/shared/protocol.js
@@ -854,26 +854,28 @@ Pool.prototype = extend(EventEmitter.pro
},
/**
* Add an actor as a child of this pool.
*/
manage: function(actor) {
if (!actor.actorID) {
actor.actorID = this.conn.allocID(actor.actorPrefix || actor.typeName);
- }
+ } else {
+ // If the actor is already registerd in a pool, remove it without destroying it.
+ // This happens for example when an addon is reloaded. To see this behavior, take a
+ // look at devtools/server/tests/unit/test_addon_reload.js
- // If the actor is already in a pool, remove it without destroying it.
- // TODO: not all actors have been moved to protocol.js, so they do not all have
- // a parent field. Remove the check for the parent once the conversion is finished
- const parent = this.poolFor(actor.actorID);
- if (parent) {
- parent.unmanage(actor);
+ // TODO: not all actors have been moved to protocol.js, so they do not all have
+ // a parent field. Remove the check for the parent once the conversion is finished
+ const parent = this.poolFor(actor.actorID);
+ if (parent) {
+ parent.unmanage(actor);
+ }
}
-
this._poolMap.set(actor.actorID, actor);
return actor;
},
/**
* Remove an actor as a child of this pool.
*/
unmanage: function(actor) {