[OpenLayers-Commits] r4780 - sandbox/tschaub/wfsv/lib/OpenLayers/Control

commits at openlayers.org commits at openlayers.org
Wed Oct 3 11:09:15 EDT 2007


Author: tcoulter
Date: 2007-10-03 11:09:13 -0400 (Wed, 03 Oct 2007)
New Revision: 4780

Modified:
   sandbox/tschaub/wfsv/lib/OpenLayers/Control/UndoRedo.js
Log:
Fixed javascript errors due to pressing undo/redo passed the end of the stack.

Modified: sandbox/tschaub/wfsv/lib/OpenLayers/Control/UndoRedo.js
===================================================================
--- sandbox/tschaub/wfsv/lib/OpenLayers/Control/UndoRedo.js	2007-10-03 14:57:45 UTC (rev 4779)
+++ sandbox/tschaub/wfsv/lib/OpenLayers/Control/UndoRedo.js	2007-10-03 15:09:13 UTC (rev 4780)
@@ -151,29 +151,31 @@
 			top = fromStack.pop();
         }
         
-		// If the feature is not on the layer and we've reached a null geometry,
-		// then we must be redoing a previous addition. Add the feature on the map.
-		if (feature.layer.getFeatureById(feature.id) == null && nextGeometry == null) {
-			feature.layer.addFeatures(feature);
-		}
-		else
-		{
-			// If we're here, we're removing a layer; if nextGeometry == null (there's nothing new to draw),
-			// we don't plan on re-adding it. Let's let everyone else know that we're removing it for good.
-			if (nextGeometry == null) {
-				this.onRemoveFeature(feature);
+		if (feature) {
+			// If the feature is not on the layer and we've reached a null geometry,
+			// then we must be redoing a previous addition. Add the feature on the map.
+			if (feature.layer.getFeatureById(feature.id) == null && nextGeometry == null) {
+				feature.layer.addFeatures(feature);
 			}
-			
-			// So, we're either undoing or redoing a feature to a previous state.
-			// Remove the feature from the layer.
-		    feature.layer.removeFeatures(feature);
-			
-			// If the previous state is not a null value, change the feature to the previous
-			// state and re-add it to the layer.
-			if (nextGeometry != null) {             
-	            feature.geometry = nextGeometry.clone();
-	            feature.layer.addFeatures(feature);
-	        }
+			else
+			{
+				// If we're here, we're removing a layer; if nextGeometry == null (there's nothing new to draw),
+				// we don't plan on re-adding it. Let's let everyone else know that we're removing it for good.
+				if (nextGeometry == null) {
+					this.onRemoveFeature(feature);
+				}
+				
+				// So, we're either undoing or redoing a feature to a previous state.
+				// Remove the feature from the layer.
+			    feature.layer.removeFeatures(feature);
+				
+				// If the previous state is not a null value, change the feature to the previous
+				// state and re-add it to the layer.
+				if (nextGeometry != null) {             
+		            feature.geometry = nextGeometry.clone();
+		            feature.layer.addFeatures(feature);
+		        }
+			}
 		}
 		
 		return feature;



More information about the Commits mailing list