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

Commit

Permalink
Merge pull request #6846 from lkcampbell/fix-6452
Browse files Browse the repository at this point in the history
Fix for issue #6452: Prevent reload commands from being repeated too quickly
  • Loading branch information
RaymondLim committed Feb 12, 2014
2 parents 25be547 + 2643d7c commit 8f8d231
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/document/DocumentCommandHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ define(function (require, exports, module) {
/** @type {Number} index to use for next, new Untitled document */
var _nextUntitledIndexToUse = 1;

/** @type {boolean} prevents reentrancy of browserReload() */
var _isReloading = false;

/** Unique token used to indicate user-driven cancellation of Save As (as opposed to file IO error) */
var USER_CANCELED = { userCanceled: true };

Expand Down Expand Up @@ -1438,12 +1441,18 @@ define(function (require, exports, module) {

return result.promise();
}

/**
* Does a full reload of the browser window
* @param {string} href The url to reload into the window
*/
function browserReload(href) {
if (_isReloading) {
return;
}

_isReloading = true;

return CommandManager.execute(Commands.FILE_CLOSE_ALL, { promptOnly: true }).done(function () {
// Give everyone a chance to save their state - but don't let any problems block
// us from quitting
Expand All @@ -1452,7 +1461,7 @@ define(function (require, exports, module) {
} catch (ex) {
console.error(ex);
}

// Disable the cache to make reloads work
_disableCache().always(function () {
// Remove all menus to assure every part of Brackets is reloaded
Expand All @@ -1462,6 +1471,8 @@ define(function (require, exports, module) {

window.location.href = href;
});
}).fail(function () {
_isReloading = false;
});
}

Expand Down

0 comments on commit 8f8d231

Please sign in to comment.