Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #26523: Crash on deleting instrument if last staff contains fretboard diagram #26703

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/engraving/dom/fret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,15 @@ PropertyValue FretDiagram::propertyDefault(Pid pid) const
return EngravingItem::propertyDefault(pid);
}

void FretDiagram::setTrack(track_idx_t val)
{
EngravingItem::setTrack(val);

if (m_harmony) {
m_harmony->setTrack(val);
}
}

//---------------------------------------------------------
// endEditDrag
//---------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/engraving/dom/fret.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ class FretDiagram final : public EngravingItem
bool setProperty(Pid propertyId, const PropertyValue&) override;
PropertyValue propertyDefault(Pid) const override;

void setTrack(track_idx_t val) override;

String accessibleInfo() const override;
String screenReaderInfo() const override;

Expand Down
7 changes: 5 additions & 2 deletions src/engraving/dom/harmony.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1073,9 +1073,12 @@ const ChordDescription* Harmony::getDescription(const String& name, const Parsed

const RealizedHarmony& Harmony::getRealizedHarmony() const
{
Fraction tick = this->tick();
const Staff* st = staff();
IF_ASSERT_FAILED(st) {
return m_realizedHarmony;
}

const Fraction tick = this->tick();
const CapoParams& capo = st->capo(tick);

int offset = 0;
Expand All @@ -1091,7 +1094,7 @@ const RealizedHarmony& Harmony::getRealizedHarmony() const
//Adjust for Nashville Notation, might be temporary
// TODO: set dirty on add/remove of keysig
if (m_harmonyType == HarmonyType::NASHVILLE && !m_realizedHarmony.valid()) {
Key key = staff()->key(tick);
Key key = st->key(tick);

//parse root
int rootTpc = function2Tpc(m_function, key);
Expand Down
15 changes: 12 additions & 3 deletions src/engraving/playback/playbackeventsrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ void PlaybackEventsRenderer::renderChordSymbol(const Harmony* chordSymbol,
return;
}

const Staff* staff = chordSymbol->staff();
IF_ASSERT_FAILED(staff) {
return;
}

const RealizedHarmony& realized = chordSymbol->getRealizedHarmony();
const RealizedHarmony::PitchMap& notes = realized.notes();

Expand All @@ -130,7 +135,7 @@ void PlaybackEventsRenderer::renderChordSymbol(const Harmony* chordSymbol,

voice_layer_idx_t voiceIdx = static_cast<voice_layer_idx_t>(chordSymbol->voice());
staff_layer_idx_t staffIdx = static_cast<staff_layer_idx_t>(chordSymbol->staffIdx());
Key key = chordSymbol->staff()->key(chordSymbol->tick());
Key key = staff->key(chordSymbol->tick());

ArticulationMap articulations = makeStandardArticulationMap(profile, eventTimestamp, duration);

Expand Down Expand Up @@ -161,15 +166,19 @@ void PlaybackEventsRenderer::renderChordSymbol(const Harmony* chordSymbol, const
return;
}

const Staff* staff = chordSymbol->staff();
IF_ASSERT_FAILED(staff) {
return;
}

const RealizedHarmony& realized = chordSymbol->getRealizedHarmony();
const RealizedHarmony::PitchMap& notes = realized.notes();

PlaybackEventList& events = result[actualTimestamp];

voice_layer_idx_t voiceIdx = static_cast<voice_layer_idx_t>(chordSymbol->voice());
staff_layer_idx_t staffIdx = static_cast<staff_layer_idx_t>(chordSymbol->staffIdx());

Key key = chordSymbol->staff()->key(chordSymbol->tick());
Key key = staff->key(chordSymbol->tick());

ArticulationMap articulations = makeStandardArticulationMap(profile, actualTimestamp, actualDuration);

Expand Down
Loading