diff layer/FlexiNoteLayer.cpp @ 792:0ba792bb235b tonioni

adding a note after the last existing one is now possible (#974)
author matthiasm
date Thu, 12 Jun 2014 14:31:48 +0100
parents 488add397d34
children bb1f2a20f7db
line wrap: on
line diff
--- a/layer/FlexiNoteLayer.cpp	Thu Jun 12 13:42:10 2014 +0100
+++ b/layer/FlexiNoteLayer.cpp	Thu Jun 12 14:31:48 2014 +0100
@@ -1281,19 +1281,22 @@
     long frame = v->getFrameForX(e->x());
     float value = getValueForY(v, e->y());
     
+    FlexiNoteModel::PointList noteList = m_model->getPoints();
+
     if (m_intelligentActions) {
         long smallestRightNeighbourFrame = 0;
-        for (FlexiNoteModel::PointList::const_iterator i = m_model->getPoints().begin();
-             i != m_model->getPoints().end(); ++i) {
+        for (FlexiNoteModel::PointList::const_iterator i = noteList.begin();
+             i != noteList.end(); ++i) {
             FlexiNote currentNote = *i;
             if (currentNote.frame > frame) {
                 smallestRightNeighbourFrame = currentNote.frame;
                 break;
             }
         }
-        
-        duration = std::min(smallestRightNeighbourFrame - frame + 1, duration);
-        duration = (duration > 0) ? duration : 0;
+        if (smallestRightNeighbourFrame > 0) {
+            duration = std::min(smallestRightNeighbourFrame - frame + 1, duration);
+            duration = (duration > 0) ? duration : 0;
+        }
     }
 
     if (!m_intelligentActions ||