OpenLayers OpenLayers

Ticket #596 (closed bug: fixed)

Opened 2 years ago

Last modified 1 year ago

map.destroy() flawed

Reported by: euzuro Assigned to:
Priority: critical Milestone: 2.4 Release
Component: Map Version:
Keywords: Cc:
State:

Description

As we've seen before, we can't iterate through an array if the action we're taking on each iteration is changing the length of the array itself.

In this case, layer.destroy() removes itself from the map, decreasing the map's layers.length.

solution is to use a while loop, popping the first layer each time.

Attachments

mapDestroy.patch (0.7 kB) - added by euzuro on 03/29/07 21:08:37.
use while instead of for. now all the layers go bye
596.patch (0.9 kB) - added by sderle on 04/01/07 17:43:38.
tschaub's take on euzuro's original patch, plus a similar fix for map.controls just in case

Change History

03/29/07 21:08:37 changed by euzuro

  • attachment mapDestroy.patch added.

use while instead of for. now all the layers go bye

03/29/07 21:51:55 changed by euzuro

  • cc deleted.
  • keywords set to review.

03/30/07 18:02:00 changed by sderle

where does the popping happen? in layer.destroy()? that should be commented in the patch if so

03/31/07 13:03:30 changed by tschaub

for(var i=this.layers.length - 1; i>=0; --i) {

would make this look less like an infinite loop - but that's just my personal bias against while loops

04/01/07 17:43:38 changed by sderle

  • attachment 596.patch added.

tschaub's take on euzuro's original patch, plus a similar fix for map.controls just in case

04/01/07 17:53:48 changed by crschmidt

Approved, go ahead to commit.

04/01/07 17:56:39 changed by sderle

  • status changed from new to closed.
  • resolution set to fixed.

07/05/07 17:02:07 changed by euzuro

  • keywords deleted.