[OpenLayers-Dev] Re: TransformFeature control destroy function
seems to have a bug
Fabian Patzke (OL)
listensammler at patzi.de
Tue Sep 21 05:53:02 EDT 2010
Andreas Hocevar-2 wrote:
>
> Hi,
> the rule is simple - a common paradigm (not only in software engineering)
> says: the one who creates something is responsible for cleaning it up.
> This means that you should not destroy features (i.e. the trasformation
> box) that others (the TransformFeature control) create.
> If you think that this is something that should be explained, please
> provide a documentation patch.
> Regards,
> Andreas.
>
That's true and totally understandable, lets say it so, I didn't realize
that some of the controls are drawing features in my layer. And so I didn't
know that I destroy something they created. I thought they have their own
temporary ones. I try to think about where this could be written down so
that others, if there are some like me, would find it. Thanks for your help
:)
Greetings,
Fabian
Andreas Hocevar-2 wrote:
>
> On Sep 21, 2010, at 11:22 , Fabian Patzke (OL) wrote:
>
>>
>> Hi,
>>
>> Andreas Hocevar-2 wrote:
>>>
>>> what you are describing here can only happen if you "delete everything
>>> in
>>> the used vector layer" *before* you "deactivate the control".
>>>
>> That's true, that was my approach. I deleted everything first.
>>
>> Andreas Hocevar-2 wrote:
>>>
>>> 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.
>>>
>> So this is my fault using a wrong sequence of actions. Maybe it should be
>> made a bit more clear somewhere that one has to follow a certain kind of
>> order to clear any digitize procedure? Because for me it was not obvious
>> that it is a fault to first empty and then deactivate and destroy
>> controls.
>>
>> Greetings,
>> Fabian
>>
>> Andreas Hocevar-2 wrote:
>>>
>>> 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.
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> Dev at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/openlayers-dev
>>>
>>>
>>
>> --
>> View this message in context:
>> http://osgeo-org.1803224.n2.nabble.com/TransformFeature-control-destroy-function-seems-to-have-a-bug-tp5550628p5553874.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.
>
> _______________________________________________
> Dev mailing list
> Dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-dev
>
>
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/TransformFeature-control-destroy-function-seems-to-have-a-bug-tp5550628p5553981.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.
More information about the Dev
mailing list