Skip to content

Commit

Permalink
Fix #298147 MusicXML: Handle measure number offsets
Browse files Browse the repository at this point in the history
Previously it was assumed that measure numbers always started at 1 and
increased by 1 for each regular measure. Now the actual measure numbers
given in the MusicXML are used within MuseScore during import to
calculate measure number offsets. During export, these offsets are
converted back into absolute numbers for use in the MusicXML.

Backport of musescore#7617, resp. duplicate of musescore#7870 part 1, culprit for quite a lot
mtest failures
  • Loading branch information
shoogle authored and Jojo-Schmitz committed Sep 23, 2021
1 parent c31b07c commit 52ab4d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions importexport/musicxml/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6130,6 +6130,7 @@ void MeasureNumberStateHandler::updateForMeasure(const Measure* const m)
}

// update measure numbers and cache result
_measureNo += m->noOffset();
_cachedAttributes = " number=";
if ((_irregularMeasureNo + _measureNo) == 2 && m->irregular()) {
_cachedAttributes += "\"0\" implicit=\"yes\"";
Expand Down
6 changes: 4 additions & 2 deletions importexport/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1969,8 +1969,8 @@ void MusicXMLParserPass2::measure(const QString& partId,
const Fraction time)
{
Q_ASSERT(_e.isStartElement() && _e.name() == "measure");
//QString number = _e.attributes().value("number").toString();
//qDebug("measure %s start", qPrintable(number));
int number = _e.attributes().value("number").toInt();
//qDebug("measure %d start", number);

Measure* measure = findMeasure(_score, time);
if (!measure) {
Expand All @@ -1979,6 +1979,8 @@ void MusicXMLParserPass2::measure(const QString& partId,
return;
}

measure->setNoOffset(measure->no() - number);

// handle implicit measure
if (_e.attributes().value("implicit") == "yes")
measure->setIrregular(true);
Expand Down

0 comments on commit 52ab4d5

Please sign in to comment.