Skip to content

Commit

Permalink
Merge pull request #4942 from mattmcclinch/287423-keysig-after-clef-c…
Browse files Browse the repository at this point in the history
…hange

fix #287423: Key signatures displayed incorrectly after clef change
  • Loading branch information
dmitrio95 committed Apr 22, 2019
2 parents 67fda19 + 981650f commit 222dfa4
Showing 1 changed file with 49 additions and 48 deletions.
97 changes: 49 additions & 48 deletions libmscore/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3607,6 +3607,55 @@ void Measure::addSystemHeader(bool isFirstSystem)
for (const Staff* staff : score()->staves()) {
const int track = staffIdx * VOICES;

if (isFirstSystem || score()->styleB(Sid::genClef)) {
// find the clef type at the previous tick
ClefTypeList cl = staff->clefType(tick() - Fraction::fromTicks(1));
// look for a clef change at the end of the previous measure
if (prevMeasure()) {
Segment* s = prevMeasure()->findSegment(SegmentType::Clef, tick());
if (s) {
Clef* c = toClef(s->element(track));
if (c)
cl = c->clefTypeList();
}
}
Clef* clef;
if (!cSegment) {
cSegment = new Segment(this, SegmentType::HeaderClef, Fraction(0,1));
cSegment->setHeader(true);
add(cSegment);
clef = 0;
}
else
clef = toClef(cSegment->element(track));
if (staff->staffType(tick())->genClef()) {
if (!clef) {
//
// create missing clef
//
clef = new Clef(score());
clef->setTrack(track);
clef->setGenerated(true);
clef->setParent(cSegment);
cSegment->add(clef);
}
if (clef->generated())
clef->setClefType(cl);
clef->setSmall(false);
clef->layout();
}
else if (clef) {
clef->parent()->remove(clef);
delete clef;
}
cSegment->createShape(staffIdx);
cSegment->setEnabled(true);
}
else {
if (cSegment)
cSegment->setEnabled(false);
}

// keep key sigs in TABs: TABs themselves should hide them
bool needKeysig = isFirstSystem || score()->styleB(Sid::genKeysig);

Expand Down Expand Up @@ -3691,54 +3740,6 @@ void Measure::addSystemHeader(bool isFirstSystem)
}
}

if (isFirstSystem || score()->styleB(Sid::genClef)) {
// find the clef type at the previous tick
ClefTypeList cl = staff->clefType(tick() - Fraction::fromTicks(1));
// look for a clef change at the end of the previous measure
if (prevMeasure()) {
Segment* s = prevMeasure()->findSegment(SegmentType::Clef, tick());
if (s) {
Clef* c = toClef(s->element(track));
if (c)
cl = c->clefTypeList();
}
}
Clef* clef;
if (!cSegment) {
cSegment = new Segment(this, SegmentType::HeaderClef, Fraction(0,1));
cSegment->setHeader(true);
add(cSegment);
clef = 0;
}
else
clef = toClef(cSegment->element(track));
if (staff->staffType(tick())->genClef()) {
if (!clef) {
//
// create missing clef
//
clef = new Clef(score());
clef->setTrack(track);
clef->setGenerated(true);
clef->setParent(cSegment);
cSegment->add(clef);
}
if (clef->generated())
clef->setClefType(cl);
clef->setSmall(false);
clef->layout();
}
else if (clef) {
clef->parent()->remove(clef);
delete clef;
}
cSegment->createShape(staffIdx);
cSegment->setEnabled(true);
}
else {
if (cSegment)
cSegment->setEnabled(false);
}
++staffIdx;
}
//
Expand Down

0 comments on commit 222dfa4

Please sign in to comment.