Just in case, to prevent any leaks due to interrupted

gestures, clear all longpress timers on EventManager.destroy()
This commit is contained in:
Aditya Bhatt
2014-03-07 18:45:52 +01:00
parent 0c139bd592
commit 77dcbf564a
+9
View File
@@ -80,6 +80,8 @@ gui.EventManager = function EventManager(odtDocument) {
eventTrap,
canvasElement = /**@type{!HTMLElement}*/(odtDocument.getCanvas().getElement()),
eventManager = this,
/**@type{!Array.<!number>}*/
longPressTimers = [],
/**@const*/LONGPRESS_DURATION = 400; // milliseconds
/**
@@ -212,6 +214,7 @@ gui.EventManager = function EventManager(odtDocument) {
detail: 1
});
}, LONGPRESS_DURATION);
longPressTimers.push(timer);
}
}
cachedState.timer = timer;
@@ -498,6 +501,12 @@ gui.EventManager = function EventManager(odtDocument) {
* @return {undefined}
*/
this.destroy = function (callback) {
// Clear all long press timers, just in case
longPressTimers.forEach(function (timer) {
runtime.clearTimeout(timer);
});
longPressTimers.length = 0;
Object.keys(compoundEvents).forEach(function (compoundEventName) {
compoundEvents[compoundEventName].destroy();
});