Skip to content

Commit

Permalink
Merge pull request #6521 from MarcSabatella/harmony-duration-crash
Browse files Browse the repository at this point in the history
fix #309852: undefined playback of chord symbol attached to fret diagram
  • Loading branch information
anatoly-os committed Sep 1, 2020
2 parents f116ed5 + b161ed8 commit 568e538
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion libmscore/harmony.h
Expand Up @@ -109,7 +109,6 @@ class Harmony final : public TextBase {
void render(const QList<RenderAction>& renderList, qreal&, qreal&, int tpc, NoteSpellingType noteSpelling = NoteSpellingType::STANDARD, NoteCaseType noteCase = NoteCaseType::AUTO);
Sid getPropertyStyle(Pid) const override;

Segment* getParentSeg() const;
Harmony* findInSeg(Segment* seg) const;

public:
Expand Down Expand Up @@ -137,6 +136,7 @@ class Harmony final : public TextBase {
Harmony* findNext() const;
Harmony* findPrev() const;
Fraction ticksTilNext(bool stopAtMeasureEnd = false) const;
Segment* getParentSeg() const;

const ChordDescription* descr() const;
const ChordDescription* descr(const QString&, const ParsedChord* pc = 0) const;
Expand Down
19 changes: 17 additions & 2 deletions libmscore/realizedharmony.cpp
Expand Up @@ -24,6 +24,7 @@
#include "harmony.h"
#include "fraction.h"
#include "segment.h"
#include "chordrest.h"

namespace Ms {

Expand Down Expand Up @@ -250,9 +251,23 @@ Fraction RealizedHarmony::getActualDuration(HDuration durationType) const
case HDuration::STOP_AT_MEASURE_END:
return _harmony->ticksTilNext(true);
break;
case HDuration::SEGMENT_DURATION:
return toSegment(_harmony->parent())->ticks();
case HDuration::SEGMENT_DURATION: {
Segment* s = _harmony->getParentSeg();
if (s) {
// TODO - use duration of chordrest on this segment / track
// currently, this will result in too short of a duration
// if there are shorter notes on other staves
// but, we can only do this up to the next harmony that is being realized,
// or elese we would get overlap
// (e.g., if the notes are dotted half / quarter, but chords are half / half,
// then we can't actually make the first chord a dotted half)
return s->ticks();
}
else {
return Fraction(0, 1);
}
break;
}
default:
return Fraction(0, 1);
}
Expand Down

0 comments on commit 568e538

Please sign in to comment.