Skip to content

Commit

Permalink
fix #22093: Crash when selecting fixed pitch LH/RH separation
Browse files Browse the repository at this point in the history
  • Loading branch information
trig-ger committed Oct 1, 2013
1 parent 6de066c commit f655e82
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions mscore/importmidi_lrhand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void splitByFixedPitch(std::multimap<int, MTrack> &tracks,
+ (int)trackOpers.LHRH.splitPitchNote;
std::multimap<ReducedFraction, MidiChord> leftHandChords;

for (auto i = srcTrack.chords.begin(); i != srcTrack.chords.end(); ++i) {
for (auto i = srcTrack.chords.begin(); i != srcTrack.chords.end(); ) {
auto &notes = i->second.notes;
QList<MidiNote> leftHandNotes;
for (auto j = notes.begin(); j != notes.end(); ) {
Expand All @@ -54,6 +54,11 @@ void splitByFixedPitch(std::multimap<int, MTrack> &tracks,
}
if (!leftHandNotes.empty())
addNewLeftHandChord(leftHandChords, leftHandNotes, i);
if (notes.isEmpty()) {
i = srcTrack.chords.erase(i);
continue;
}
++i;
}
if (!leftHandChords.empty())
insertNewLeftHandTrack(tracks, it, leftHandChords);
Expand All @@ -67,7 +72,7 @@ void splitByHandWidth(std::multimap<int, MTrack> &tracks,
const int octave = 12;
std::multimap<ReducedFraction, MidiChord> leftHandChords;
// chords after MIDI import are sorted by onTime values
for (auto i = srcTrack.chords.begin(); i != srcTrack.chords.end(); ++i) {
for (auto i = srcTrack.chords.begin(); i != srcTrack.chords.end(); ) {
auto &notes = i->second.notes;
QList<MidiNote> leftHandNotes;
const int minPitch = notes.front().pitch;
Expand Down Expand Up @@ -97,6 +102,11 @@ void splitByHandWidth(std::multimap<int, MTrack> &tracks,
}
if (!leftHandNotes.empty())
addNewLeftHandChord(leftHandChords, leftHandNotes, i);
if (notes.isEmpty()) {
i = srcTrack.chords.erase(i);
continue;
}
++i;
}
if (!leftHandChords.empty())
insertNewLeftHandTrack(tracks, it, leftHandChords);
Expand Down

0 comments on commit f655e82

Please sign in to comment.