changeset 76:a595de3e6f8d

Fix invalid call to parts.erase(parts.end()), which can crash and never does anything good. I think this is the intended behaviour.
author Chris Cannam
date Thu, 24 Jan 2019 15:07:04 +0000
parents f1717a01dd9a
children 85742047ee37
files segmentino/Segmentino.cpp
diffstat 1 files changed, 29 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/segmentino/Segmentino.cpp	Thu Jan 24 15:06:13 2019 +0000
+++ b/segmentino/Segmentino.cpp	Thu Jan 24 15:07:04 2019 +0000
@@ -1218,6 +1218,19 @@
 // Merge Nulls
 void mergenulls(vector<Part> &parts)
 {
+/*
+    cerr << "Segmentino: mergenulls: before: "<< endl;
+    for (int iPart=0; iPart<(int)parts.size(); ++iPart) {
+        cerr << parts[iPart].letter << ": ";
+        for (int iIndex=0; iIndex<(int)parts[iPart].indices.size(); ++iIndex) {
+            cerr << parts[iPart].indices[iIndex];
+            if (iIndex+1 < (int)parts[iPart].indices.size()) {
+                cerr << ", ";
+            }
+        }
+        cerr << endl;
+    }
+*/
     for (int iPart=0; iPart<(int)parts.size(); ++iPart)
     {
         
@@ -1258,12 +1271,27 @@
                     newVectorPart[newpartind].n = newVectorPart[newpartind].n+1;
                 }
             }
-            parts.erase (parts.end());
+            parts.erase (parts.begin() + iPart);
             
             for (int i=0; i<(int)newVectorPart.size(); ++i)
                 parts.push_back(newVectorPart[i]);
+
+            break;
         }
     }
+/*
+    cerr << "Segmentino: mergenulls: after: "<< endl;
+    for (int iPart=0; iPart<(int)parts.size(); ++iPart) {
+        cerr << parts[iPart].letter << ": ";
+        for (int iIndex=0; iIndex<(int)parts[iPart].indices.size(); ++iIndex) {
+            cerr << parts[iPart].indices[iIndex];
+            if (iIndex+1 < (int)parts[iPart].indices.size()) {
+                cerr << ", ";
+            }
+        }
+        cerr << endl;
+    }
+*/
 }
 
 /* ------ Segmentation ------ */