[OpenLayers-Dev] Fwd: [OpenLayers-Commits] r6230 - trunk/openlayers/lib/OpenLayers

Erik Uzureau euzuro at gmail.com
Tue Feb 12 13:10:50 EST 2008

reasonable. i see the logic in but do not like the idea of a
flag to say dont destroy me (and i imagine you dont like
it either :-) so yes, i think the best course of action is just
if (control != null) control.destroy();

oh, i just had a thought. another solution to this would be

make two addControl functions. one would be the public
api and the other would be an internal one. so when you

map.addControl( new OL.Control.Navigation());

then the map would know that it is in charge of destroying the
control on map destroy.

but then something like

this.fooControl = new Control();

... the map would know that fooControl is *not* under its domain.

in the short term, i think the simple if (null) solution is sufficient, but
it might be worth considering the latter... maybe when we do that
fabled memory review


On Feb 12, 2008 11:29 AM, Christopher Schmidt <crschmidt at metacarta.com> wrote:
> On Tue, Feb 12, 2008 at 10:51:04AM -0600, Erik Uzureau wrote:
> > i dont know what the specific case is here, but i know the following
> > rule tends to work in 99% of cases:
> >
> > if you create it, you destroy it. if you register it, you unregister it.
> The problem is that with controls, the map attempts to destroy them all,
> even though it creates relatively few of them. Without a flag to say
> 'Don't destroy me' (or a more invasive destruction procedure documented
> for all OpenLayers apps), there's no way to prevent duplicate
> destruction.
> Regards,
> --
> Christopher Schmidt
> MetaCarta
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev

More information about the Dev mailing list