From 1420dad8e1f32c94a7a1db58ad489682bddeaf8b Mon Sep 17 00:00:00 2001 From: AlexThomasEOG Date: Thu, 7 Apr 2016 18:42:34 -0500 Subject: [PATCH] Track Scale Range Handler for final destroy() The scaleRangeHandler was being tracked outside of the _handlers list. In some scenarios this handler would never be released. This fix confirms that this handler is tracked for a final destroy --- .../dijit/LayerControl/controls/_Control.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/viewer/js/gis/dijit/LayerControl/controls/_Control.js b/viewer/js/gis/dijit/LayerControl/controls/_Control.js index 6dd6a8b08..9ee4cf867 100644 --- a/viewer/js/gis/dijit/LayerControl/controls/_Control.js +++ b/viewer/js/gis/dijit/LayerControl/controls/_Control.js @@ -2,7 +2,7 @@ define([ 'dojo/_base/declare', 'dojo/_base/lang', - //'dojo/_base/array', + 'dojo/_base/array', 'dojo/on', 'dojo/topic', 'dojo/dom-construct', @@ -16,7 +16,7 @@ define([ ], function ( declare, lang, - //array, + array, on, topic, domConst, @@ -194,11 +194,23 @@ define([ _scaleRangeChange: function () { if (this.layer.minScale !== 0 || this.layer.maxScale !== 0) { this._checkboxScaleRange(); + if (this._scaleRangeHandler) { + var handlerIndex = array.indexOf(this._handlers, this._scaleRangeHandler); + if (handlerIndex !== -1) { + this._handlers[handlerIndex].remove(); + this._handlers.splice(handlerIndex, 1); + } + } this._scaleRangeHandler = this.layer.getMap().on('zoom-end', lang.hitch(this, '_checkboxScaleRange')); + this._handlers.push(this._scaleRangeHandler); } else { this._checkboxScaleRange(); if (this._scaleRangeHandler) { - this._scaleRangeHandler.remove(); + var handlerIndex2 = array.indexOf(this._handlers, this._scaleRangeHandler); + if (handlerIndex2 !== -1) { + this._handlers[handlerIndex2].remove(); + this._handlers.splice(handlerIndex2, 1); + } this._scaleRangeHandler = null; } }