Skip to content

Commit

Permalink
Track Scale Range Handler for final destroy()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
AlexThomasEOG committed Apr 7, 2016
1 parent b6cceeb commit 1420dad
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions viewer/js/gis/dijit/LayerControl/controls/_Control.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
define([
'dojo/_base/declare',
'dojo/_base/lang',
//'dojo/_base/array',
'dojo/_base/array',
'dojo/on',
'dojo/topic',
'dojo/dom-construct',
Expand All @@ -16,7 +16,7 @@ define([
], function (
declare,
lang,
//array,
array,
on,
topic,
domConst,
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 1420dad

Please sign in to comment.