Bug 1062604 - Check for actors in WebIDE before use. r=paul

This commit is contained in:
J. Ryan Stinnett 2014-09-03 16:23:00 +02:00
parent 80a947ffdb
commit 716fccd801
5 changed files with 35 additions and 17 deletions

View File

@ -80,10 +80,13 @@ WebappsStore.prototype = {
},
_feedStore: function() {
if (!this._webAppsActor) {
return promise.resolve();
}
this._listenToApps();
return this._getAllApps()
.then(this._getRunningApps.bind(this))
.then(this._getAppsIcons.bind(this))
.then(this._getAppsIcons.bind(this));
},
_listenToApps: function() {

View File

@ -84,7 +84,7 @@ function CheckLockState() {
if (AppManager.connection &&
AppManager.connection.status == Connection.Status.CONNECTED &&
AppManager.deviceFront) {
AppManager.preferenceFront) {
// ADB check
if (AppManager.selectedRuntime instanceof USBRuntime) {

View File

@ -139,6 +139,7 @@ let UI = {
break;
case "project-is-not-running":
case "project-is-running":
case "list-tabs-response":
this.updateCommands();
break;
case "runtime":
@ -596,16 +597,18 @@ let UI = {
let runtimePanelButton = document.querySelector("#runtime-panel-button");
if (AppManager.connection.status == Connection.Status.CONNECTED) {
screenshotCmd.removeAttribute("disabled");
permissionsCmd.removeAttribute("disabled");
if (AppManager.deviceFront) {
detailsCmd.removeAttribute("disabled");
permissionsCmd.removeAttribute("disabled");
screenshotCmd.removeAttribute("disabled");
}
disconnectCmd.removeAttribute("disabled");
detailsCmd.removeAttribute("disabled");
runtimePanelButton.setAttribute("active", "true");
} else {
screenshotCmd.setAttribute("disabled", "true");
permissionsCmd.setAttribute("disabled", "true");
disconnectCmd.setAttribute("disabled", "true");
detailsCmd.setAttribute("disabled", "true");
permissionsCmd.setAttribute("disabled", "true");
screenshotCmd.setAttribute("disabled", "true");
disconnectCmd.setAttribute("disabled", "true");
runtimePanelButton.removeAttribute("active");
}
@ -826,7 +829,13 @@ let Cmds = {
let runtimeappsHeaderNode = document.querySelector("#panel-header-runtimeapps");
if (AppManager.connection.status == Connection.Status.CONNECTED) {
let sortedApps = AppManager.webAppsStore.object.all;
sortedApps = sortedApps.sort((a, b) => {
return a.name > b.name;
});
let mainProcess = AppManager.isMainProcessDebuggable();
if (AppManager.connection.status == Connection.Status.CONNECTED &&
(sortedApps.length > 0 || mainProcess)) {
runtimeappsHeaderNode.removeAttribute("hidden");
} else {
runtimeappsHeaderNode.setAttribute("hidden", "true");
@ -837,7 +846,7 @@ let Cmds = {
runtimeAppsNode.firstChild.remove();
}
if (AppManager.isMainProcessDebuggable()) {
if (mainProcess) {
let panelItemNode = document.createElement("toolbarbutton");
panelItemNode.className = "panel-item";
panelItemNode.setAttribute("label", Strings.GetStringFromName("mainProcess_label"));
@ -853,10 +862,6 @@ let Cmds = {
}, true);
}
let sortedApps = AppManager.webAppsStore.object.all;
sortedApps = sortedApps.sort((a, b) => {
return a.name > b.name;
});
for (let i = 0; i < sortedApps.length; i++) {
let app = sortedApps[i];
let panelItemNode = document.createElement("toolbarbutton");

View File

@ -224,10 +224,15 @@ let DeviceFront = protocol.FrontClass(DeviceActor, {
const _knownDeviceFronts = new WeakMap();
exports.getDeviceFront = function(client, form) {
if (_knownDeviceFronts.has(client))
if (!form.deviceActor) {
return null;
}
if (_knownDeviceFronts.has(client)) {
return _knownDeviceFronts.get(client);
}
let front = new DeviceFront(client, form);
_knownDeviceFronts.set(client, front);
return front;
}
};

View File

@ -116,8 +116,13 @@ let PreferenceFront = protocol.FrontClass(PreferenceActor, {
const _knownPreferenceFronts = new WeakMap();
exports.getPreferenceFront = function(client, form) {
if (_knownPreferenceFronts.has(client))
if (!form.preferenceActor) {
return null;
}
if (_knownPreferenceFronts.has(client)) {
return _knownPreferenceFronts.get(client);
}
let front = new PreferenceFront(client, form);
_knownPreferenceFronts.set(client, front);