diff --git a/Sources/VLModel.cpp b/Sources/VLModel.cpp index 58ee351..6467753 100644 --- a/Sources/VLModel.cpp +++ b/Sources/VLModel.cpp @@ -887,18 +887,21 @@ void VLSong::DelNote(size_t measure, VLFraction at) fMeasures.pop_back(); } -void VLSong::ExtendNote(size_t measure, VLFraction at) +VLNote VLSong::ExtendNote(size_t measure, VLFraction at) { VLNoteList::iterator i = fMeasures[measure].fMelody.begin(); VLNoteList::iterator end= fMeasures[measure].fMelody.end(); + if (i==end) + return VLNote(); // Empty song, do nothing + for (VLFraction t(0); i != end && t+i->fDuration <= at; ++i) t += i->fDuration; if (i == end) --i; if (i->fPitch == VLNote::kNoPitch) - return; // Don't extend rests + return *i; // Don't extend rests for (;;) { VLNoteList::iterator j=i; @@ -942,6 +945,7 @@ void VLSong::ExtendNote(size_t measure, VLFraction at) } break; } + return *i; } bool VLSong::IsNonEmpty() const diff --git a/Sources/VLModel.h b/Sources/VLModel.h index c896278..778af7d 100644 --- a/Sources/VLModel.h +++ b/Sources/VLModel.h @@ -334,7 +334,7 @@ public: void AddNote(VLLyricsNote note, size_t measure, VLFraction at); void DelChord(size_t measure, VLFraction at); void DelNote(size_t measure, VLFraction at); - void ExtendNote(size_t measure, VLFraction at); + VLNote ExtendNote(size_t measure, VLFraction at); void AddRepeat(size_t beginMeasure, size_t endMeasure, int times); void DelRepeat(size_t beginMeasure, size_t endMeasure); void AddEnding(size_t beginMeasure, size_t endMeasure, size_t volta); diff --git a/Sources/VLSheetViewNotes.mm b/Sources/VLSheetViewNotes.mm index 7f18c0a..e8eceb0 100644 --- a/Sources/VLSheetViewNotes.mm +++ b/Sources/VLSheetViewNotes.mm @@ -32,7 +32,7 @@ } [[self document] willChangeSong]; if (fCursorAccidental == kMusicExtendCursor) - [self song]->ExtendNote(fCursorMeasure, fCursorAt); + newNote = [self song]->ExtendNote(fCursorMeasure, fCursorAt); else if (fClickMode == 'k') [self song]->DelNote(fCursorMeasure, fCursorAt); else