From 77dcbf564aec42104f7d4bd6150dd059b84998e2 Mon Sep 17 00:00:00 2001 From: Aditya Bhatt Date: Fri, 7 Mar 2014 15:30:02 +0100 Subject: [PATCH] Just in case, to prevent any leaks due to interrupted gestures, clear all longpress timers on EventManager.destroy() --- webodf/lib/gui/EventManager.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/webodf/lib/gui/EventManager.js b/webodf/lib/gui/EventManager.js index 6933764c..46ef6c4d 100644 --- a/webodf/lib/gui/EventManager.js +++ b/webodf/lib/gui/EventManager.js @@ -80,6 +80,8 @@ gui.EventManager = function EventManager(odtDocument) { eventTrap, canvasElement = /**@type{!HTMLElement}*/(odtDocument.getCanvas().getElement()), eventManager = this, + /**@type{!Array.}*/ + 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(); });