scholarslab/Neatline — Issue #41: Multiple bugs on layer reload and edit
Author: davidmcclure
Created: 2011-10-24 19:33:59+00:00
State: open
Labels: bug

There is a suite of bugs triggered by the core vectoring edit tasks that appear to be related to a series of OpenLayers callbacks that get automatically called when map "controls" are added, removed, activated, and deactivated. Any/all of these produce bugs:

* Open an edit item form, add a feature, and click save.
(If this doesn't produce a OL error, close the form and then try to open any other edit form)
* Open an item form and toggle the space record for that item on and off.

I am pretty sure that the essence of the problem is this: when a controls is added, you have to specify the layers that the control acts on. So, when I add modifyFeatures, I pass in the array of _currentVectorLayers. But then the code makes changes to that stack of layers - it might get totally replaced if a save is made and the stack is rebuilt from scratch; if an item edit form is opened for an item without an existing spatial record, a new vector layer is added.

Once these changes occur, it appears that OL chokes when virtually anything at all happens to the old control - if any method is called on it, even if the control is just destroyed. Once these errors get thrown, the whole JavaScript application shuts down.

My current approach to just aggressively destroy and re-instantiate these controls before and after any conceivable change to the layers stack. This has not worked so far.