Эх сурвалжийг харах

erase const iterator fixed

Fabian Peter Hammerle 9 жил өмнө
parent
commit
a0647d9bc9
5 өөрчлөгдсөн 11 нэмэгдсэн , 22 устгасан
  1. 1 11
      BeatSequence.cpp
  2. 1 3
      BeatSequence.h
  3. 7 7
      PlaybackScreen.cpp
  4. 1 0
      build
  5. 1 1
      midi

+ 1 - 11
BeatSequence.cpp

@@ -45,16 +45,6 @@ void BeatSequenceNoteInformation::unregisterMessage(BeatSequence::BeatIndex beat
     }
 }
 
-const midi::MessageList& BeatSequence::at(BeatIndex beatIndex) const
-{
-    return parent::at(beatIndex);
-}
-
-const midi::MessageList& BeatSequence::operator[](BeatIndex beatIndex) const
-{
-    return parent::operator[](beatIndex);
-}
-
 void BeatSequence::resize(BeatIndex size)
 {
     parent::resize(size);
@@ -73,7 +63,7 @@ void BeatSequence::pushBackMessage(BeatIndex beatIndex, std::shared_ptr<midi::Me
     registerMessage(beatIndex, msg_ptr);
 }
 
-void BeatSequence::eraseMessage(BeatIndex beatIndex, midi::MessageList::const_iterator msg_it)
+void BeatSequence::eraseMessage(BeatIndex beatIndex, midi::MessageList::iterator msg_it)
 {
     unregisterMessage(beatIndex, *msg_it);
     parent::at(beatIndex).erase(msg_it);

+ 1 - 3
BeatSequence.h

@@ -29,12 +29,10 @@ class BeatSequence : public midi::BeatSequence
     NoteInfoMap noteInfos;
 
 public:
-    const midi::MessageList& at(BeatIndex beatIndex) const;
-    const midi::MessageList& operator[](BeatIndex beatIndex) const;
     void resize(BeatIndex size);
     void pushFrontMessage(BeatIndex beatIndex, std::shared_ptr<midi::Message> msg_ptr);
     void pushBackMessage(BeatIndex beatIndex, std::shared_ptr<midi::Message> msg_ptr);
-    void eraseMessage(BeatIndex beatIndex, midi::MessageList::const_iterator msg_it);
+    void eraseMessage(BeatIndex beatIndex, midi::MessageList::iterator msg_it);
     void expand(BeatIndex factor);
     void reduceToNeighbour(BeatIndex factor);
     void reduceErasingConflicts(BeatIndex factor);

+ 7 - 7
PlaybackScreen.cpp

@@ -195,11 +195,11 @@ void PlaybackScreen::toggleOnMessage(std::shared_ptr<midi::NoteOnMessage> onMsg_
     const BeatSequenceNoteInformation& noteInfo
         = sequencer.beats.getNoteInfo(onMsg_ptr->channel, onMsg_ptr->pitch);
 
-    const midi::MessageList& beat = sequencer.beats[beatIndex];
-    midi::MessageList::const_iterator beatOnMsg_it = beat.find(*onMsg_ptr);
+    midi::MessageList& beat = sequencer.beats[beatIndex];
+    midi::MessageList::iterator beatOnMsg_it = beat.find(*onMsg_ptr);
     if(beatOnMsg_it == beat.end()) {
         // further steps depend on whether a off message has been inserted at the current position
-        midi::MessageList::const_iterator beatOffMsg_it = beat.find(onMsg_ptr->toOffMessage(0));     
+        midi::MessageList::iterator beatOffMsg_it = beat.find(onMsg_ptr->toOffMessage(0));
         BeatIndex nextBeatIndex = (beatIndex + 1) % sequencer.beats.size();
         if(beatOffMsg_it == beat.end()) {
             // is there a ongoing msg, that has to be stopped first?
@@ -222,9 +222,9 @@ void PlaybackScreen::toggleOnMessage(std::shared_ptr<midi::NoteOnMessage> onMsg_
                     sequencer.beats.pushFrontMessage(beatIndex, std::shared_ptr<midi::Message>(new midi::NoteOffMessage(offMsg)));
                     // since the new note will be stopped on the next beat,
                     // remove this extra off message, which no longer stops the preceding note.
-                    const midi::MessageList& precedingOnFollowingOffBeat
+                    midi::MessageList& precedingOnFollowingOffBeat
                         = sequencer.beats[*precedingOnFollowingOffMsgBeatIndex_it];
-                    const midi::MessageList::const_iterator precedingOnFollowingOffMsg_it
+                    const midi::MessageList::iterator precedingOnFollowingOffMsg_it
                         = precedingOnFollowingOffBeat.find(offMsg);
                     assert(precedingOnFollowingOffMsg_it != precedingOnFollowingOffBeat.end());
                     sequencer.beats.eraseMessage(
@@ -253,8 +253,8 @@ void PlaybackScreen::toggleOnMessage(std::shared_ptr<midi::NoteOnMessage> onMsg_
             assert(*offPrecedingOnBeatIndex_it >= beatIndex);
             if(*offPrecedingOnBeatIndex_it == beatIndex) {
                 // no relevant on message before off found. so off may be removed.
-                const midi::MessageList& followingOffBeat = sequencer.beats[followingOffBeatIndex];
-                midi::MessageList::const_iterator followingOffMsg_it = followingOffBeat.find(offMsg);
+                midi::MessageList& followingOffBeat = sequencer.beats[followingOffBeatIndex];
+                midi::MessageList::iterator followingOffMsg_it = followingOffBeat.find(offMsg);
                 assert(followingOffMsg_it != followingOffBeat.end());
                 sequencer.beats.eraseMessage(*followingOffBeatIndex_it, followingOffMsg_it);
             }

+ 1 - 0
build

@@ -1,4 +1,5 @@
 #!/bin/bash
+set -e
 
 cd "$( dirname "$0" )"
 

+ 1 - 1
midi

@@ -1 +1 @@
-Subproject commit 2acee77f4d46e075e3d56f0482dcd329d75b4be4
+Subproject commit f82e5a1c2eec79d6b86fd4dd289b571dac5e03f4