Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Prevent errors at destroy or deactivate.

  • Loading branch information...
commit b1f0ef73dcb9a3cf82529c25d1e98a4212b20113 1 parent d4b2fe9
@jorix authored
Showing with 20 additions and 6 deletions.
  1. +20 −6 lib/FeaturePopups.js
View
26 lib/FeaturePopups.js
@@ -476,6 +476,10 @@ OpenLayers.Control.FeaturePopups = OpenLayers.Class(OpenLayers.Control, {
* APIMethod: destroy
*/
destroy: function() {
+ if (!this.events) {
+ // Don't destroy again (if events === null then control was destroyed)
+ return;
+ }
this.deactivate();
for (var popupType in this.popupObjs) {
this.popupObjs[popupType].destroy();
@@ -490,12 +494,17 @@ OpenLayers.Control.FeaturePopups = OpenLayers.Class(OpenLayers.Control, {
this.layers = null;
this.handlerBox && this.handlerBox.destroy();
this.handlerBox = null;
- this.controls.select && this.controls.select.destroy();
- if (this.controls.hover) {
- this.controls.hover.events.un(this.hoverListeners);
- this.controls.hover.destroy();
+
+ var controls = this.controls;
+ // Another process may have destroyed the controls, don't destroy again.
+ controls.select && controls.select.events &&
+ this.controls.select.destroy();
+ if (controls.hover && controls.hover.events) {
+ controls.hover.events.un(this.hoverListeners);
+ controls.hover.destroy();
}
this.controls = null;
+
OpenLayers.Control.prototype.destroy.apply(this, arguments);
},
@@ -565,8 +574,13 @@ OpenLayers.Control.FeaturePopups = OpenLayers.Class(OpenLayers.Control, {
}
this.handlerBox && this.handlerBox.deactivate();
var controls = this.controls;
- controls.hover && controls.hover.deactivate();
- controls.select && controls.select.deactivate();
+ // OL bug: Another process may have destroyed the controls, then
+ // deactivate fails (if events === null then the control was
+ // destroyed)
+ controls.hover && controls.hover.events &&
+ controls.hover.deactivate();
+ controls.select && controls.select.events &&
+ controls.select.deactivate();
for (var popupType in this.popupObjs) {
this.popupObjs[popupType].clearPopup();
}
Please sign in to comment.
Something went wrong with that request. Please try again.