Skip to content

Commit

Permalink
fixed reading of scores with excerpts
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanPudashkin committed Aug 6, 2021
1 parent 77a7e30 commit f6e0502
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 41 deletions.
4 changes: 2 additions & 2 deletions src/engraving/libmscore/masterscore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ Score::FileError MasterScore::read(XmlReader& e, bool ignoreVersionError, mu::en
error = compat::Read114::read114(this, e);
} else if (mscVersion() <= 207) {
error = compat::Read206::read206(this, e);
} else if (mscVersion() <= 400) {
} else if (mscVersion() < 400) {
error = compat::Read302::read302(this, e);
} else {
error = doRead(e);
Expand All @@ -559,7 +559,7 @@ Score::FileError MasterScore::doRead(XmlReader& e)
} else if (tag == "programRevision") {
setMscoreRevision(e.readIntHex());
} else if (tag == "Score") {
if (!Score::read400(e)) {
if (!Score::readScore400(e)) {
if (e.error() == QXmlStreamReader::CustomError) {
return FileError::FILE_CRITICALLY_CORRUPTED;
}
Expand Down
79 changes: 40 additions & 39 deletions src/engraving/libmscore/read400.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,6 @@ using namespace Ms;

bool Score::read400(XmlReader& e)
{
// HACK
// style setting compatibility settings for minor versions
// this allows new style settings to be added
// with different default values for older vs newer scores
// note: older templates get the default values for older scores
// these can be forced back in MuseScore::getNewFile() if necessary
QString programVersion = masterScore()->mscoreVersion();
bool disableHarmonyPlay = MScore::harmonyPlayDisableCompatibility && !MScore::testMode;
if (!programVersion.isEmpty() && programVersion < "3.5" && disableHarmonyPlay) {
style().set(Sid::harmonyPlay, false);
}

if (!e.readNextStartElement()) {
qDebug("%s: xml file is empty", qPrintable(e.getDocName()));
return false;
Expand Down Expand Up @@ -72,38 +60,23 @@ bool Score::read400(XmlReader& e)
return false;
}

connectTies();
relayoutForStyles(); // force relayout if certain style settings are enabled

_fileDivision = MScore::division;

// Make sure every instrument has an instrumentId set.
for (Part* part : parts()) {
const InstrumentList* il = part->instruments();
for (auto it = il->begin(); it != il->end(); it++) {
static_cast<Instrument*>(it->second)->updateInstrumentId();
}
}

fixTicks();

for (Part* p : qAsConst(_parts)) {
p->updateHarmonyChannels(false);
}

masterScore()->rebuildMidiMapping();
masterScore()->updateChannel();

for (Staff* staff : staves()) {
staff->updateOttava();
}

// createPlayEvents();
return true;
}

bool Score::readScore400(XmlReader& e)
{
// HACK
// style setting compatibility settings for minor versions
// this allows new style settings to be added
// with different default values for older vs newer scores
// note: older templates get the default values for older scores
// these can be forced back in MuseScore::getNewFile() if necessary
QString programVersion = masterScore()->mscoreVersion();
bool disableHarmonyPlay = MScore::harmonyPlayDisableCompatibility && !MScore::testMode;
if (!programVersion.isEmpty() && programVersion < "3.5" && disableHarmonyPlay) {
style().set(Sid::harmonyPlay, false);
}

while (e.readNextStartElement()) {
e.setTrack(-1);
const QStringRef& tag(e.name());
Expand Down Expand Up @@ -236,5 +209,33 @@ bool Score::readScore400(XmlReader& e)
return false;
}

connectTies();
relayoutForStyles(); // force relayout if certain style settings are enabled

_fileDivision = MScore::division;

// Make sure every instrument has an instrumentId set.
for (Part* part : parts()) {
const InstrumentList* il = part->instruments();
for (auto it = il->begin(); it != il->end(); it++) {
static_cast<Instrument*>(it->second)->updateInstrumentId();
}
}

fixTicks();

for (Part* p : qAsConst(_parts)) {
p->updateHarmonyChannels(false);
}

masterScore()->rebuildMidiMapping();
masterScore()->updateChannel();

for (Staff* staff : staves()) {
staff->updateOttava();
}

// createPlayEvents();

return true;
}

0 comments on commit f6e0502

Please sign in to comment.