Resolves #401 fix listeners

This commit is contained in:
Peter Cottle 2017-02-17 09:45:20 +09:00
parent 5545e7f94c
commit aa4b8959e5
2 changed files with 10 additions and 3 deletions

View file

@ -21,6 +21,8 @@ var events = assign(
} }
} }
); );
// Allow unlimited listeners, so FF doesnt break
events.setMaxListeners(0);
var commandUI; var commandUI;
var sandbox; var sandbox;
var eventBaton; var eventBaton;

View file

@ -39,10 +39,10 @@ function GitVisuals(options) {
this.branchCollection.on('add', this.addBranchFromEvent, this); this.branchCollection.on('add', this.addBranchFromEvent, this);
this.branchCollection.on('remove', this.removeBranch, this); this.branchCollection.on('remove', this.removeBranch, this);
this.tagCollection.on('add', this.addTagFromEvent, this); this.tagCollection.on('add', this.addTagFromEvent, this);
this.tagCollection.on('remove', this.removeTag, this); this.tagCollection.on('remove', this.removeTag, this);
this.deferred = []; this.deferred = [];
this.flipFraction = 0.65; this.flipFraction = 0.65;
@ -96,6 +96,11 @@ GitVisuals.prototype.resetAll = function() {
GitVisuals.prototype.tearDown = function() { GitVisuals.prototype.tearDown = function() {
this.resetAll(); this.resetAll();
this.paper.remove(); this.paper.remove();
// Unregister the refresh tree listener so we dont accumulate
// these over time. However we aren't calling tearDown in
// some places... but this is an improvement
var Main = require('../app');
Main.getEvents().removeListener('refreshTree', this.refreshTree);
}; };
GitVisuals.prototype.assignGitEngine = function(gitEngine) { GitVisuals.prototype.assignGitEngine = function(gitEngine) {
@ -520,7 +525,7 @@ GitVisuals.prototype.calcTagStacks = function() {
var map = {}; var map = {};
_.each(tags, function(tag) { _.each(tags, function(tag) {
var thisId = tag.target.get('id'); var thisId = tag.target.get('id');
map[thisId] = map[thisId] || []; map[thisId] = map[thisId] || [];
map[thisId].push(tag); map[thisId].push(tag);
map[thisId].sort(function(a, b) { map[thisId].sort(function(a, b) {