QML Measure.firstSegment and Measure.lastSegment seems inverted

• Dec 17, 2015 - 02:32
Type
Plugins
Severity
S4 - Minor
Status
closed
Project

I'm playing around with developing plugins and it seems that the firstSegment and lastSegment properties from a Measure work inverted (working with MuseScore 2.0.2 official release on Windows7)

onRun: {
      console.log('first: ' + curScore.firstMeasure.firstSegment.segmentType + ' ' + curScore.firstMeasure.firstSegment.tick + '\n\tlast: ' + curScore.firstMeasure.lastSegment.segmentType + ' ' + curScore.firstMeasure.lastSegment.tick)
      var startSeg = curScore.firstMeasure.lastSegment;
      do {
            console.log('startSeg type: ' + segmentTypeToText(startSeg.segmentType));
            var an = startSeg.annotations;
            for (var i = 0; i < an.length; i++) {
            console.log('\t' + i + ' ' + an[i].type + ' ' + an[i]._name() + ' ' + an[i].userName() + ' ' + an[i].subtypeName());
                if (an[i].type === Element.TEMPO_TEXT) {
                    console.log("Tempo: " + an[i].tempo);
                    break;
                }
            }
            startSeg = startSeg.nextInMeasure;
      } while (startSeg != null);
      console.log('last: ' + curScore.lastMeasure.lastSegment.segmentType + ' ' + curScore.lastMeasure.lastSegment.tick + ' ' + curScore.lastMeasure.firstSegment.tick)
    }

Using the attached file the following output is observed:
Debug: first: 256 1920
last: 1 0
Debug: startSeg type: Clef
Debug: startSeg type: TimeSig
Debug: startSeg type: Chord/Rest
Debug: 0 33 Tempo Tempo
Debug: Tempo: 1
Debug: startSeg type: Chord/Rest
Debug: startSeg type: Chord/Rest
Debug: startSeg type: Chord/Rest
Debug: startSeg type: EndBarLine
Debug: last: 128 5760 7680

Note the ticks recorded for first/lastSegment respectively. By changing the initial assignment for var startSeg to be the firstSegment, the loop won't find any other elements in the Measure further indicating that the property values have been swapped.

Attachment Size
titel.mscz 4.2 KB

Comments

QML definition is indeed swapped: Found in measure.h {syntaxhighlighter brush:c;first-line:116;class-name:'Measure'} Q_PROPERTY(Ms::Segment* firstSegment READ last)
Q_PROPERTY(Ms::Segment* lastSegment READ first){/syntaxhighlighter}
Still new to this while git thing, but I'll see if I can add the change/pull request to this issue (however this is to be done..)

Looks pretty good.
One small Thing though: had you assigned the issue to yourself when you started to work on it, I'd have not tried to do the same thing ;-)