diff --git a/libmscore/read114.cpp b/libmscore/read114.cpp index 45acfba54963d..f810748e25d66 100644 --- a/libmscore/read114.cpp +++ b/libmscore/read114.cpp @@ -1140,6 +1140,11 @@ static void readVolta114(XmlReader& e, Volta* volta) else if (!readTextLineProperties114(e, volta)) e.unknown(); } + if (volta->anchor() != Volta::VOLTA_ANCHOR) { + // Volta strictly assumes that its anchor is measure, so don't let old scores override this. + qWarning("Correcting volta anchor type from %d to %d", int(volta->anchor()), int(Volta::VOLTA_ANCHOR)); + volta->setAnchor(Volta::VOLTA_ANCHOR); + } volta->setOffset(QPointF()); // ignore offsets volta->setAutoplace(true); } @@ -1449,7 +1454,7 @@ static void readMeasure(Measure* m, int staffIdx, XmlReader& e) QList graceNotes; //sort tuplet elements. needed for nested tuplets #22537 - for (Tuplet* t : e.tuplets()) + for (Tuplet*& t : e.tuplets()) t->sortElements(); e.tuplets().clear(); e.setTrack(staffIdx * VOICES); @@ -2080,11 +2085,11 @@ static void readMeasure(Measure* m, int staffIdx, XmlReader& e) } // For nested tuplets created with MuseScore 1.3 tuplet dialog (i.e. "Other..." dialog), // the parent tuplet was not set. Try to infere if the tuplet was actually a nested tuplet - for (Tuplet* tuplet : e.tuplets()) { + for (Tuplet*& tuplet : e.tuplets()) { Fraction tupletTick = tuplet->tick(); Fraction tupletDuration = tuplet->actualTicks() - Fraction::fromTicks(1); std::vector tElements = tuplet->elements(); - for (Tuplet* tuplet2 : e.tuplets()) { + for (Tuplet*& tuplet2 : e.tuplets()) { if ((tuplet2->tuplet()) || (tuplet2->voice() != tuplet->voice())) // already a nested tuplet or in a different voice continue; // int possibleDuration = tuplet2->duration().ticks() * tuplet->ratio().denominator() / tuplet->ratio().numerator() - 1; @@ -2529,7 +2534,7 @@ static void readPart(Part* part, XmlReader& e) part->setPartName(part->instrument()->trackName()); if (part->instrument()->useDrumset()) { - for (Staff* staff : *part->staves()) { + for (Staff*& staff : *part->staves()) { int lines = staff->lines(Fraction(0,1)); int bf = staff->barLineFrom(); int bt = staff->barLineTo(); @@ -2677,7 +2682,7 @@ static void readStyle(MStyle* style, XmlReader& e) else if (tag == "ChordList") { style->chordList()->clear(); style->chordList()->read(e); - for (ChordFont f : style->chordList()->fonts) { + for (ChordFont& f : style->chordList()->fonts) { if (f.family == "MuseJazz") { f.family = "MuseJazz Text"; } @@ -2989,7 +2994,7 @@ Score::FileError MasterScore::read114(XmlReader& e) setEnableVerticalSpread(false); - for (Staff* s : staves()) { + for (Staff*& s : staves()) { int idx = s->idx(); int track = idx * VOICES; @@ -3154,7 +3159,7 @@ Score::FileError MasterScore::read114(XmlReader& e) // // sanity check for barLineSpan and update ottavas // - for (Staff* staff : staves()) { + for (Staff*& staff : staves()) { int barLineSpan = staff->barLineSpan(); int idx = staff->idx(); int n = nstaves(); @@ -3230,7 +3235,7 @@ Score::FileError MasterScore::read114(XmlReader& e) fixTicks(); - for (Part* p : parts()) { + for (Part*& p : parts()) { p->updateHarmonyChannels(false); } diff --git a/libmscore/read206.cpp b/libmscore/read206.cpp index c651a3b44ced2..471cb23f529b1 100644 --- a/libmscore/read206.cpp +++ b/libmscore/read206.cpp @@ -1757,7 +1757,7 @@ bool readChordRestProperties206(XmlReader& e, ChordRest* ch) ch->add(el); } else if (tag == "leadingSpace" || tag == "trailingSpace") { - qDebug("ChordRest: %s obsolete", tag.toLocal8Bit().data()); + qDebug("ChordRest: %s obsolete", tag.toLocal8Bit().constData()); e.skipCurrentElement(); } else if (tag == "Beam") { @@ -1818,12 +1818,12 @@ bool readChordRestProperties206(XmlReader& e, ChordRest* ch) if (spanner->type() == ElementType::SLUR) spanner->setStartElement(ch); if (e.pasteMode()) { - for (ScoreElement* el : spanner->linkList()) { + for (ScoreElement*& el : spanner->linkList()) { if (el == spanner) continue; Spanner* ls = static_cast(el); ls->setTick(spanner->tick()); - for (ScoreElement* ee : ch->linkList()) { + for (ScoreElement*& ee : ch->linkList()) { ChordRest* cr = toChordRest(ee); if (cr->score() == ee->score() && cr->staffIdx() == ls->staffIdx()) { ls->setTrack(cr->track()); @@ -1844,12 +1844,12 @@ bool readChordRestProperties206(XmlReader& e, ChordRest* ch) if (start) spanner->setTrack(start->track()); if (e.pasteMode()) { - for (ScoreElement* el : spanner->linkList()) { + for (ScoreElement*& el : spanner->linkList()) { if (el == spanner) continue; Spanner* ls = static_cast(el); ls->setTick2(spanner->tick2()); - for (ScoreElement* ee : ch->linkList()) { + for (ScoreElement*& ee : ch->linkList()) { ChordRest* cr = toChordRest(ee); if (cr->score() == ee->score() && cr->staffIdx() == ls->staffIdx()) { ls->setTrack2(cr->track()); @@ -2020,7 +2020,7 @@ bool readChordProperties206(XmlReader& e, Chord* ch) static void convertDoubleArticulations(Chord* chord, XmlReader& e) { std::vector pairableArticulations; - for (Articulation* a : chord->articulations()) { + for (Articulation*& a : chord->articulations()) { if (a->isStaccato() || a->isTenuto() || a->isAccent() || a->isMarcato()) { pairableArticulations.push_back(a); @@ -2213,6 +2213,11 @@ static void readVolta206(XmlReader& e, Volta* volta) else if (!readTextLineProperties(e, volta)) e.unknown(); } + if (volta->anchor() != Volta::VOLTA_ANCHOR) { + // Volta strictly assumes that its anchor is measure, so don't let old scores override this. + qWarning("Correcting volta anchor type from %d to %d", int(volta->anchor()), int(Volta::VOLTA_ANCHOR)); + volta->setAnchor(Volta::VOLTA_ANCHOR); + } adjustPlacement(volta); } @@ -3403,7 +3408,7 @@ static void readStyle(MStyle* style, XmlReader& e) style->chordList()->clear(); style->chordList()->read(e); style->setCustomChordList(true); - for (ChordFont f : style->chordList()->fonts) { + for (ChordFont& f : style->chordList()->fonts) { if (f.family == "MuseJazz") { f.family = "MuseJazz Text"; } @@ -3704,7 +3709,7 @@ static bool readScore(Score* score, XmlReader& e) #endif score->fixTicks(); - for (Part* p : score->parts()) { + for (Part*& p : score->parts()) { p->updateHarmonyChannels(false); } @@ -3815,10 +3820,10 @@ Score::FileError MasterScore::read206(XmlReader& e) setEnableVerticalSpread(false); int id = 1; - for (LinkedElements* le : e.linkIds()) + for (LinkedElements*& le : e.linkIds()) le->setLid(this, id++); - for (Staff* s : staves()) + for (Staff*& s : staves()) s->updateOttava(); // fix segment span @@ -3858,7 +3863,7 @@ Score::FileError MasterScore::read206(XmlReader& e) // fix positions // offset = saved offset - layout position doLayout(); - for (auto i : e.fixOffsets()) { + for (auto& i : e.fixOffsets()) { i.first->setOffset(i.second - i.first->pos()); } diff --git a/libmscore/spanner.cpp b/libmscore/spanner.cpp index ad498e1fb0c70..088d8ec214296 100644 --- a/libmscore/spanner.cpp +++ b/libmscore/spanner.cpp @@ -720,7 +720,7 @@ Note* Spanner::startElementFromSpanner(Spanner* sp, Element* newEnd) int newTrack = (newEnd->track() - oldEnd->track()) + oldStart->track(); // look in notes linked to oldStart for a note with the // same score as new score and appropriate track - for (ScoreElement* newEl : oldStart->linkList()) + for (ScoreElement*& newEl : oldStart->linkList()) if (toNote(newEl)->score() == score && toNote(newEl)->track() == newTrack) { newStart = toNote(newEl); break; @@ -753,7 +753,7 @@ Note* Spanner::endElementFromSpanner(Spanner* sp, Element* newStart) int newTrack = newStart->track() + (oldEnd->track() - oldStart->track()); // look in notes linked to oldEnd for a note with the // same score as new score and appropriate track - for (ScoreElement* newEl : oldEnd->linkList()) + for (ScoreElement*& newEl : oldEnd->linkList()) if (toNote(newEl)->score() == score && toNote(newEl)->track() == newTrack) { newEnd = toNote(newEl); break; @@ -872,6 +872,7 @@ Measure* Spanner::startMeasure() const Measure* Spanner::endMeasure() const { + Q_ASSERT(anchor() == Spanner::Anchor::MEASURE); return toMeasure(_endElement); } diff --git a/libmscore/volta.cpp b/libmscore/volta.cpp index 200397da2a9b5..42c4d3b557b75 100644 --- a/libmscore/volta.cpp +++ b/libmscore/volta.cpp @@ -19,7 +19,6 @@ #include "style.h" #include "system.h" #include "tempo.h" -#include "text.h" #include "xml.h" #include @@ -142,7 +141,11 @@ void Volta::read(XmlReader& e) const QStringRef& tag(e.name()); if (tag == "endings") { QString s = e.readElementText(); +#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) + QStringList sl = s.split(",", Qt::SkipEmptyParts); +#else QStringList sl = s.split(",", QString::SkipEmptyParts); +#endif _endings.clear(); for (const QString& l : qAsConst(sl)) { int i = l.simplified().toInt(); @@ -154,6 +157,11 @@ void Volta::read(XmlReader& e) else if (!readProperties(e)) e.unknown(); } + if (this->anchor() != Volta::VOLTA_ANCHOR) { + // Volta strictly assumes that its anchor is measure, so don't let old scores override this. + qWarning("Correcting volta anchor type from %d to %d", int(this->anchor()), int(Volta::VOLTA_ANCHOR)); + this->setAnchor(Volta::VOLTA_ANCHOR); + } } //--------------------------------------------------------- diff --git a/libmscore/volta.h b/libmscore/volta.h index 488c81bd002f6..6f2a1d2c6fc8a 100644 --- a/libmscore/volta.h +++ b/libmscore/volta.h @@ -49,9 +49,9 @@ class VoltaSegment final : public TextLineBaseSegment { class Volta final : public TextLineBase { QList _endings; - static constexpr Anchor VOLTA_ANCHOR = Anchor::MEASURE; public: + static constexpr Anchor VOLTA_ANCHOR = Anchor::MEASURE; enum class Type : char { OPEN, CLOSED };