diff layer/TimeValueLayer.cpp @ 860:4a5d144bd5d0 tonioni

Merge from default branch
author Chris Cannam
date Tue, 09 Sep 2014 16:36:21 +0100
parents 6c6e34b09688
children 33157c3f0e80
line wrap: on
line diff
--- a/layer/TimeValueLayer.cpp	Tue Sep 02 16:23:48 2014 +0100
+++ b/layer/TimeValueLayer.cpp	Tue Sep 09 16:36:21 2014 +0100
@@ -733,13 +733,21 @@
     i = close.begin();
 
     // Scan through the close points first, then the more distant ones
-    // if no suitable close one is found
+    // if no suitable close one is found. So the while-termination
+    // condition here can only happen once i has passed through the
+    // whole of the close container and then the whole of the separate
+    // points container. The two iterators are totally distinct, but
+    // have the same type so we cheekily use the same variable and a
+    // single loop for both.
 
     while (i != points.end()) {
 
-        if (i == close.end()) {
-            i = points.begin();
-            distant = true;
+        if (!distant) {
+            if (i == close.end()) {
+                // switch from the close container to the points container
+                i = points.begin();
+                distant = true;
+            }
         }
 
 	if (snap == SnapRight) {
@@ -1788,7 +1796,10 @@
                 (0, tr("Choose value calculation"),
                  text, options, prevSelection, &ok);
 
-            if (!ok) return false;
+            if (!ok) {
+                delete command;
+                return false;
+            }
             int selection = 0;
             generation = Labeller::ValueNone;