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

Commit

Permalink
Fix bug #2961 (Documents may leak due to listeners left on FileEntry) -
Browse files Browse the repository at this point in the history
Simplify by just directly pinging refcounted documents from
DocumentManager.notifyPathNameChanged(). FileUtils no longer triggers a
"rename" event on FileEntry objects and we no longer have a per-Document
listener.

Also, enable block comments in XML files.
  • Loading branch information
peterflynn committed Feb 28, 2013
1 parent dde9848 commit 47018dc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
14 changes: 10 additions & 4 deletions src/document/DocumentManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -600,9 +600,6 @@ define(function (require, exports, module) {
this.refreshText(rawText, initialTimestamp);

this._updateLanguage();
// TODO: remove this listener when the document object is obsolete.
// But when is this the case? When _refCount === 0?
$(this.file).on("rename", this._updateLanguage.bind(this));

// This is a good point to clean up any old dangling Documents
_gcDocuments();
Expand Down Expand Up @@ -963,6 +960,13 @@ define(function (require, exports, module) {
}
};

/** Called when Document.file has been modified (due to a rename) */
Document.prototype._notifyFilePathChanged = function () {
// File extension may have changed
this._updateLanguage();
};


/**
* Gets an existing open Document for the given file, or creates a new one if the Document is
* not currently open ('open' means referenced by the UI somewhere). Always use this method to
Expand Down Expand Up @@ -1178,7 +1182,9 @@ define(function (require, exports, module) {
keysToDelete.push(path);

// Update document file
FileUtils.updateFileEntryPath(_openDocuments[newKey].file, oldName, newName, isFolder);
var doc = _openDocuments[newKey];
FileUtils.updateFileEntryPath(doc.file, oldName, newName, isFolder);
doc._notifyFilePathChanged();

if (!isFolder) {
// If the path name is a file, there can only be one matched entry in the open document
Expand Down
2 changes: 0 additions & 2 deletions src/file/FileUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,6 @@ define(function (require, exports, module) {
}
}

$(entry).triggerHandler("rename", [oldFullPath, fullPath]);

return true;
}

Expand Down
3 changes: 2 additions & 1 deletion src/language/languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"xml": {
"name": "XML",
"mode": "xml",
"fileExtensions": ["svg", "xml", "wxs", "wxl"]
"fileExtensions": ["svg", "xml", "wxs", "wxl"],
"blockComment": ["<!--", "-->"]
},

"php": {
Expand Down

0 comments on commit 47018dc

Please sign in to comment.