Bug 1070430 - Resolve races with tab projects. r=paul

This commit is contained in:
J. Ryan Stinnett 2014-09-22 04:28:00 -04:00
parent 65c5e9792a
commit 47c61a8ef9
3 changed files with 22 additions and 9 deletions

View File

@ -134,13 +134,15 @@ let UI = {
this.updateCommands();
break;
case "project":
this.updateTitle();
this.destroyToolbox();
this.updateCommands();
this.updateProjectButton();
this.openProject();
this.autoStartProject();
break;
this._updatePromise = Task.spawn(function() {
UI.updateTitle();
yield UI.destroyToolbox();
UI.updateCommands();
UI.updateProjectButton();
UI.openProject();
UI.autoStartProject();
});
return;
case "project-is-not-running":
case "project-is-running":
case "list-tabs-response":
@ -159,6 +161,7 @@ let UI = {
case "install-progress":
this.updateProgress(Math.round(100 * details.bytesSent / details.totalBytes));
};
this._updatePromise = promise.resolve();
},
openInBrowser: function(url) {
@ -717,11 +720,12 @@ let UI = {
destroyToolbox: function() {
if (this.toolboxPromise) {
this.toolboxPromise.then(toolbox => {
return this.toolboxPromise.then(toolbox => {
toolbox.destroy();
this.toolboxPromise = null;
}, console.error);
}
return promise.resolve();
},
createToolbox: function() {

View File

@ -122,7 +122,11 @@ TabStore.prototype = {
return this._selectedTab;
},
set selectedTab(tab) {
if (this._selectedTab === tab) {
return;
}
this._selectedTab = tab;
this._selectedTabTargetPromise = null;
// Attach to the tab to follow navigation events
if (this._selectedTab) {
this.getTargetForTab();
@ -160,6 +164,11 @@ TabStore.prototype = {
chrome: false
});
});
this._selectedTabTargetPromise.then(target => {
target.once("close", () => {
this._selectedTabTargetPromise = null;
});
});
return this._selectedTabTargetPromise;
},

View File

@ -110,7 +110,7 @@ function waitForUpdate(win, update) {
return;
}
win.AppManager.off("app-manager-update", onUpdate);
deferred.resolve();
deferred.resolve(win.UI._updatePromise);
});
return deferred.promise;
}