Clear global events every once in a while

This should presumably fix a memory leak from jslider binding
global events and not bothering unbinding them or even making them
easy to unbind.
This commit is contained in:
Guangcong Luo 2013-05-22 16:02:58 -05:00
parent e3aa7cc3c4
commit e3a9ab68af
2 changed files with 12 additions and 0 deletions

View File

@ -58,6 +58,7 @@
if (this.exportMode) {
this.exportMode = false;
} else if (this.curSet) {
app.clearGlobalListeners();
this.curSet = null;
} else if (this.curTeam) {
this.curTeam = null;
@ -579,6 +580,7 @@
curChartName: '',
updateChart: function() {
var type = this.curChartType;
app.clearGlobalListeners();
if (type === 'stats') {
this.updateStatForm();
return;
@ -775,6 +777,7 @@
this.$chart.html(buf);
var self = this;
this.suppressSliderCallback = true;
app.clearGlobalListeners();
this.$chart.find('.evslider').slider({
from: 0,
to: 252,
@ -1898,6 +1901,10 @@
} while (template && template.species && !alreadyChecked[template.speciesid]);
Tools.movelists[pokemon] = moves;
}
},
destroy: function() {
app.clearGlobalListeners();
Room.prototype.destroy.call(this);
}
}, {
// static

View File

@ -862,6 +862,11 @@
}
});
},
clearGlobalListeners: function() {
// jslider doesn't clear these when it should,
// so we have to do it for them :/
$(document).off('click touchstart mousedown touchmove mousemove touchend mouseup');
},
/*********************************************************
* Rooms