Skip to content

Commit

Permalink
fix #273302: Fermata loses assignment to voice and direction
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmcclinch committed Dec 20, 2018
1 parent 4dd37ec commit 34f261d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 26 deletions.
4 changes: 2 additions & 2 deletions libmscore/chordrest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,15 +472,15 @@ Element* ChordRest::drop(EditData& data)
}

case ElementType::FERMATA:
e->setPlacement(track() & 1 ? Placement::BELOW : Placement::ABOVE);
for (Element* el: segment()->annotations())
if (el->isFermata() && (el->track() == track())) {
if (el->subtype() == e->subtype()) {
delete e;
return el;
}
else {
if (el->placeBelow())
e->setPlacement(Placement::BELOW);
e->setPlacement(el->placement());
e->setTrack(track());
e->setParent(segment());
score()->undoChangeElement(el, e);
Expand Down
2 changes: 1 addition & 1 deletion libmscore/fermata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ QVariant Fermata::propertyDefault(Pid propertyId) const
{
switch (propertyId) {
case Pid::PLACEMENT:
return int(Placement::ABOVE);
return int(track() & 1 ? Placement::BELOW : Placement::ABOVE);
case Pid::TIME_STRETCH:
return 1.0; // articulationList[int(articulationType())].timeStretch;
case Pid::PLAY:
Expand Down
2 changes: 2 additions & 0 deletions libmscore/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2260,6 +2260,8 @@ void Measure::readVoice(XmlReader& e, int staffIdx, bool irregular)
// hack - needed because tick tags are unreliable in 1.3 scores
// for symbols attached to anything but a measure
el->setTrack(e.track());
if (el->isFermata())
el->setPlacement(el->track() & 1 ? Placement::BELOW : Placement::ABOVE);
el->read(e);
segment = getSegment(SegmentType::ChordRest, e.tick());
segment->add(el);
Expand Down
2 changes: 2 additions & 0 deletions libmscore/paste.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ bool Score::pasteStaff(XmlReader& e, Segment* dst, int dstStaff)
) {
Element* el = Element::name2Element(tag, this);
el->setTrack(e.track()); // a valid track might be necessary for el->read() to work
if (el->isFermata())
el->setPlacement(el->track() & 1 ? Placement::BELOW : Placement::ABOVE);
el->read(e);

Measure* m = tick2measure(e.tick());
Expand Down
44 changes: 21 additions & 23 deletions libmscore/read206.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2457,6 +2457,8 @@ Element* readArticulation(ChordRest* cr, XmlReader& e)
SymId sym = SymId::fermataAbove; // default -- backward compatibility (no type = ufermata in 1.2)
ArticulationAnchor anchor = ArticulationAnchor::TOP_STAFF;
Direction direction = Direction::AUTO;
double timeStretch = 0.0;
bool useDefaultPlacement = true;

while (e.readNextStartElement()) {
const QStringRef& tag(e.name());
Expand Down Expand Up @@ -2506,6 +2508,8 @@ Element* readArticulation(ChordRest* cr, XmlReader& e)
sym = al[i].id;
bool up = al[i].up;
direction = up ? Direction::UP : Direction::DOWN;
if ((direction == Direction::DOWN) != (cr->track() & 1))
useDefaultPlacement = false;
break;
}
}
Expand All @@ -2526,7 +2530,6 @@ Element* readArticulation(ChordRest* cr, XmlReader& e)
case SymId::fermataVeryLongAbove:
case SymId::fermataVeryLongBelow:
el = new Fermata(sym, cr->score());
setFermataPlacement(el, anchor, direction);
break;
default:
el = new Articulation(sym, cr->score());
Expand All @@ -2535,32 +2538,21 @@ Element* readArticulation(ChordRest* cr, XmlReader& e)
};
}
else if (tag == "anchor") {
if (!el)
useDefaultPlacement = false;
if (!el || el->isFermata())
anchor = ArticulationAnchor(e.readInt());
else {
if (el->isFermata()) {
anchor = ArticulationAnchor(e.readInt());
setFermataPlacement(el, anchor, direction);
}
else
el->readProperties(e);
}
else
el->readProperties(e);
}
else if (tag == "direction") {
if (!el)
useDefaultPlacement = false;
if (!el || el->isFermata())
direction = toDirection(e.readElementText());
else {
if (!el->isFermata())
el->readProperties(e);
}
else
el->readProperties(e);
}
else if (tag == "timeStretch") {
if (el && el->isFermata())
el->setProperty(Pid::TIME_STRETCH ,e.readDouble());
else {
qDebug("line %lld: read206: skipping <timeStretch>", e.lineNumber());
e.skipCurrentElement();
}
timeStretch = e.readDouble();
}
else {
if (!el) {
Expand All @@ -2571,9 +2563,15 @@ Element* readArticulation(ChordRest* cr, XmlReader& e)
}
}
// Special case for "no type" = ufermata, with missing subtype tag
if (!el) {
if (!el)
el = new Fermata(sym, cr->score());
setFermataPlacement(el, anchor, direction);
if (el->isFermata()) {
if (timeStretch != 0.0)
el->setProperty(Pid::TIME_STRETCH, timeStretch);
if (useDefaultPlacement)
el->setPlacement(cr->track() & 1 ? Placement::BELOW : Placement::ABOVE);
else
setFermataPlacement(el, anchor, direction);
}
el->setTrack(cr->track());
return el;
Expand Down

0 comments on commit 34f261d

Please sign in to comment.