Skip to content

Commit

Permalink
Merge pull request #3833 from brdvd/fix/tstamp-slurs
Browse files Browse the repository at this point in the history
Fix failed assertion on tstamp slur
  • Loading branch information
lpugin authored Oct 18, 2024
2 parents 8ebb1c8 + 0b86584 commit 3e32c86
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/calcslurdirectionfunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ FunctorCode CalcSlurDirectionFunctor::VisitSlur(Slur *slur)
if (slur->HasBulge()) {
LogWarning("Mixed curve direction is ignored for slurs with prescribed bulge.");
}
else if (start->Is(TIMESTAMP_ATTR) || end->Is(TIMESTAMP_ATTR)) {
LogWarning("Mixed curve direction is ignored for slurs with tstamp boundary.");
}
else {
const int startStaffN = start->GetAncestorStaff(RESOLVE_CROSS_STAFF)->GetN();
const int endStaffN = end->GetAncestorStaff(RESOLVE_CROSS_STAFF)->GetN();
Expand Down
12 changes: 8 additions & 4 deletions src/slur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,15 +527,17 @@ const Staff *Slur::CalculateExtremalStaff(const Staff *staff, int xMin, int xMax
bool Slur::IsElementBelow(const LayerElement *element, const Staff *startStaff, const Staff *endStaff) const
{
assert(element);
assert(startStaff);
assert(endStaff);
// startStaff and endStaff may be NULL (if the boundary is a tstamp)
// however, slurs with tstamp should never have S-shape

switch (this->GetDrawingCurveDir()) {
case SlurCurveDirection::Above: return true;
case SlurCurveDirection::Below: return false;
case SlurCurveDirection::AboveBelow:
assert(startStaff);
return (element->GetAncestorStaff(RESOLVE_CROSS_STAFF)->GetN() == startStaff->GetN());
case SlurCurveDirection::BelowAbove:
assert(endStaff);
return (element->GetAncestorStaff(RESOLVE_CROSS_STAFF)->GetN() == endStaff->GetN());
default: return false;
}
Expand All @@ -544,15 +546,17 @@ bool Slur::IsElementBelow(const LayerElement *element, const Staff *startStaff,
bool Slur::IsElementBelow(const FloatingPositioner *positioner, const Staff *startStaff, const Staff *endStaff) const
{
assert(positioner);
assert(startStaff);
assert(endStaff);
// startStaff and endStaff may be NULL (if the boundary is a tstamp)
// however, slurs with tstamp should never have S-shape

switch (this->GetDrawingCurveDir()) {
case SlurCurveDirection::Above: return true;
case SlurCurveDirection::Below: return false;
case SlurCurveDirection::AboveBelow:
assert(startStaff);
return (positioner->GetAlignment()->GetStaff()->GetN() == startStaff->GetN());
case SlurCurveDirection::BelowAbove:
assert(endStaff);
return (positioner->GetAlignment()->GetStaff()->GetN() == endStaff->GetN());
default: return false;
}
Expand Down

0 comments on commit 3e32c86

Please sign in to comment.