Ticket #2430 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

make OverviewMap.destroy more robust

Reported by: elemoine Owned by:
Priority: minor Milestone: 2.9 Release
Component: Control.OverviewMap Version: 2.8
Keywords: Cc:
State: Complete

Description

the OverviewMap control may produce JavaScript errors when it's destroyed. This happens if the control is destroyed while its update has never been called.

update is called by draw if map.getExtent doesn't return null. If the map doesn't have layers when draw is called then update is not called and the control cannot be destroyed.

Attachments

test-2430.diff Download (0.7 KB) - added by elemoine 3 years ago.
patch-2430-r9955-A0.diff Download (1.5 KB) - added by elemoine 3 years ago.

Change History

Changed 3 years ago by elemoine

Changed 3 years ago by elemoine

the second paragraph of the ticket description isn't entirely correct. It is correct that draw calls update only if map.getExtent doesn't return null. But this doesn't actually occur in the case where draw is called while the map doesn't have layers (indeed, this particular case is dealt with at the beginning of the draw method). However map.getExtent does return null when the map has no center.

So this sequence produces a JavaScript error:

map = new OpenLayers.Map('map'); 
map.addLayer(new OpenLayers.Layer("layer", {isBaseLayer: true})); 
control = new OpenLayers.Control.OverviewMap(); 
map.addControl(control); 
control.destroy();

(see test-2430.diff Download)

Changed 3 years ago by elemoine

Changed 3 years ago by elemoine

patch-2430-r9955-A0.diff Download fixes it. Tests pass in FF3. Please review.

Changed 3 years ago by elemoine

  • state set to Review

Changed 3 years ago by elemoine

  • owner elemoine deleted

Changed 3 years ago by fredj

  • state changed from Review to Commit

Please commit (tests and fix)

Changed 3 years ago by elemoine

fredj, thanks for the review. I'm not committing the test since it doesn't test anything, I had attached it just to show how to reproduce the bug.

Changed 3 years ago by elemoine

  • status changed from new to closed
  • state changed from Commit to Complete
  • resolution set to fixed

(In [9957]) make OverviewMap.destroy more robust, r=fredj (closes #2430)

Note: See TracTickets for help on using tickets.