crash while tying note at end of score

• Mar 1, 2009 - 20:28

pressing + at the last note in the score so tying to an note "behind the score" crashes.
It seems that adding the tie works. But the chord added isn't in the score yet, so at line 1074 in slur.cpp

int sysIdx1 = systems->indexOf(s1);
int sysIdx2 = systems->indexOf(s2, sysIdx1);
unsigned nsegs = sysIdx2 - sysIdx1 + 1;
unsigned onsegs = segments.size();

the sysIdx2 has a (unsigned)-1 as value while onsegs ist 0.
#1080 ff
if (nsegs != onsegs) {
if (nsegs > onsegs) {
int n = nsegs - onsegs;
// here n becomes -1
for (int i = 0; i < n; ++i) { // the loop has already finished since "-1 < 0"
SlurSegment* s = new SlurSegment(score()); // and so no SlurSegments are created

The crash happens then at line 1104 when accessing the vector segments with index 0 since the vector is still empty.

I don't know how to fix this. To check the given conditions (systems->indexOf(s2, sysIdx1) returns a "NO-INDEX" value would be helpful, but maybe the failure is rather to add the tie in beyond the score.

Bug found in revision #1605 (and earlier).


Do you still have an unanswered question? Please log in first to post your question.