[OpenLayers-Dev] TransformFeature control destroy function seems to have a bug

Andreas Hocevar ahocevar at opengeo.org
Mon Sep 20 10:22:43 EDT 2010


Hi,

what you are describing here can only happen if you "delete everything in the used vector layer" *before* you "deactivate the control".

If you have double-checked that you deactivate the control before removing the features from the layer and still see the issue, then please create a ticket with a test case or a minimal example that shows the problem.

Regards,
Andreas.

On Sep 20, 2010, at 16:07 , Fabian Patzke (OL) wrote:

> 
> Hi, it seems that the TransformFeature control has a broken destroy function
> or maybe its just me doing something forbidden. When you try to destroy the
> control there can be an error in line 565. For me it happens when I do the
> following.
> - start the map
> - start using the TransformFeature control
> - deactivate the control and delete everything in the used vector layer (I
> do this because I want a clear map after I used any kind of digi control)
> - using TransformFeature.destroy() now throws an error, because there is no
> geometry in the box left.
> 
> shouldn't there be a kind of check if the box has no geometry?
> 
> If someone else thinks that is a bug and not me using it the wrong way, I
> would create a ticket.
> Greetings,
> Fabian
> 
> I made this patch and it works for me:
> 
> Index: lib/OpenLayers/Control/TransformFeature.js
> ===================================================================
> --- lib/OpenLayers/Control/TransformFeature.js	(revision 10773)
> +++ lib/OpenLayers/Control/TransformFeature.js	(working copy)
> @@ -561,12 +561,14 @@
>      */
>     destroy: function() {
>         var geom;
> -        for(var i=0; i<8; ++i) {
> -            geom = this.box.geometry.components[i];
> -            geom._handle.destroy();
> -            geom._handle = null;
> -            geom._rotationHandle && geom._rotationHandle.destroy();
> -            geom._rotationHandle = null;
> +        if (this.box.geometry != null) {
> +            for(var i=0; i<8; ++i) {
> +                geom = this.box.geometry.components[i];
> +                geom._handle.destroy();
> +                geom._handle = null;
> +                geom._rotationHandle && geom._rotationHandle.destroy();
> +                geom._rotationHandle = null;
> +            }
>         }
>         this.box.destroy();
>         this.box = null;
> -- 
> View this message in context: http://osgeo-org.1803224.n2.nabble.com/TransformFeature-control-destroy-function-seems-to-have-a-bug-tp5550628p5550628.html
> Sent from the OpenLayers Dev mailing list archive at Nabble.com.
> _______________________________________________
> Dev mailing list
> Dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-dev



-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.



More information about the Dev mailing list