Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Loading a project is now only complete after the active document (if …
Browse files Browse the repository at this point in the history
…present) has been loaded
  • Loading branch information
DennisKehrig committed Jan 7, 2013
1 parent 8a2858b commit 15fa7bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/document/DocumentManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ define(function (require, exports, module) {
* @private
* Initializes the working set.
*/
function _projectOpen() {
function _projectOpen(e) {
_isProjectChanging = false;

// file root is appended for each project
Expand Down Expand Up @@ -1124,7 +1124,9 @@ define(function (require, exports, module) {
}

if (activeFile) {
CommandManager.execute(Commands.FILE_OPEN, { fullPath: activeFile });
var promise = CommandManager.execute(Commands.FILE_OPEN, { fullPath: activeFile });
// Add this promise to the event's promises to signal that this handler isn't done yet
e.promises.push(promise);
}
}

Expand Down
9 changes: 6 additions & 3 deletions src/project/ProjectManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -782,10 +782,13 @@ define(function (require, exports, module) {

resultRenderTree.done(function () {
if (projectRootChanged) {
$(exports).triggerHandler("projectOpen", _projectRoot);
// Allow asynchronous event handlers to finish before resolving result by collecting promises from them
var promises = [];
$(exports).triggerHandler({ type: "projectOpen", promises: promises }, [_projectRoot, promises]);
$.when.apply($, promises).pipe(result.resolve, result.reject);
} else {
result.resolve();
}

result.resolve();
});
resultRenderTree.fail(function () {
PerfUtils.terminateMeasurement(perfTimerName);
Expand Down

0 comments on commit 15fa7bb

Please sign in to comment.