Bug 1448499 - Destroy deviceFront when destroying the toolbox;r=jryans

MozReview-Commit-ID: IMlKbiaUKu7

--HG--
extra : rebase_source : 746806af98af61f3db7aea732654c766c594bd03
This commit is contained in:
Julian Descottes 2018-03-23 23:19:36 +01:00
Родитель 8bccddc2a4
Коммит 50d1673187
2 изменённых файлов: 21 добавлений и 0 удалений

Просмотреть файл

@ -71,6 +71,8 @@ loader.lazyRequireGetter(this, "StyleSheetsFront",
"devtools/shared/fronts/stylesheets", true);
loader.lazyRequireGetter(this, "buildHarLog",
"devtools/client/netmonitor/src/har/har-builder-utils", true);
loader.lazyRequireGetter(this, "getKnownDeviceFront",
"devtools/shared/fronts/device", true);
loader.lazyGetter(this, "domNodeConstants", () => {
return require("devtools/shared/dom-node-constants");
@ -2765,6 +2767,14 @@ Toolbox.prototype = {
this._styleSheets = null;
}
// Destroy the device front for the current client if any.
// A given DeviceFront instance can cached and shared between different panels, so
// destroying it is the responsibility of the toolbox.
let deviceFront = getKnownDeviceFront(this.target.client);
if (deviceFront) {
deviceFront.destroy();
}
// Detach the thread
detachThread(this._threadClient);
this._threadClient = null;

Просмотреть файл

@ -38,6 +38,17 @@ const DeviceFront = protocol.FrontClassWithSpec(deviceSpec, {
const _knownDeviceFronts = new WeakMap();
/**
* Retrieve the device front already created for the provided client, if available.
*/
exports.getKnownDeviceFront = function(client) {
return _knownDeviceFronts.get(client);
};
/**
* Only one DeviceFront is created for a given client, afterwards the instance is cached
* and returned immediately.
*/
exports.getDeviceFront = function(client, form) {
if (!form.deviceActor) {
return null;