when select feature control is destroyed and layers parameter was an array, the root container is not moved correctly, p=jorix, r=ahocevar,me (closes #2502)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@10115 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
bartvde
2010-03-19 09:00:41 +00:00
parent 1757d4082e
commit c54dc76d15
2 changed files with 16 additions and 0 deletions

View File

@@ -233,6 +233,9 @@ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, {
* Method: destroy * Method: destroy
*/ */
destroy: function() { destroy: function() {
if(this.active && this.layers) {
this.map.removeLayer(this.layer);
}
OpenLayers.Control.prototype.destroy.apply(this, arguments); OpenLayers.Control.prototype.destroy.apply(this, arguments);
if(this.layers) { if(this.layers) {
this.layer.destroy(); this.layer.destroy();

View File

@@ -397,6 +397,19 @@
map.destroy(); map.destroy();
} }
function test_destroy(t) {
t.plan(1);
var map = new OpenLayers.Map("map");
var layer1 = new OpenLayers.Layer.Vector();
map.addLayer(layer1);
var control = new OpenLayers.Control.SelectFeature([layer1]);
map.addControl(control);
control.activate();
control.destroy();
t.eq(layer1.renderer.getRenderLayerId(), layer1.id,
"Root container moved correctly when control is destroyed and layers was an array parameter");
}
</script> </script>
</head> </head>
<body> <body>