From b6b58123be3c3f7da07fa0807df763d135de9cb3 Mon Sep 17 00:00:00 2001 From: Roman Pudashkin Date: Mon, 24 Feb 2025 12:25:48 +0200 Subject: [PATCH] added asserts --- src/engraving/dom/harmony.cpp | 7 +++++-- src/engraving/playback/playbackeventsrenderer.cpp | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/engraving/dom/harmony.cpp b/src/engraving/dom/harmony.cpp index f8b0184bc6e42..66c698be5f6dd 100644 --- a/src/engraving/dom/harmony.cpp +++ b/src/engraving/dom/harmony.cpp @@ -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; @@ -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); diff --git a/src/engraving/playback/playbackeventsrenderer.cpp b/src/engraving/playback/playbackeventsrenderer.cpp index d5f4446cdc153..15fc98f31812a 100644 --- a/src/engraving/playback/playbackeventsrenderer.cpp +++ b/src/engraving/playback/playbackeventsrenderer.cpp @@ -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(); @@ -130,7 +135,7 @@ void PlaybackEventsRenderer::renderChordSymbol(const Harmony* chordSymbol, voice_layer_idx_t voiceIdx = static_cast(chordSymbol->voice()); staff_layer_idx_t staffIdx = static_cast(chordSymbol->staffIdx()); - Key key = chordSymbol->staff()->key(chordSymbol->tick()); + Key key = staff->key(chordSymbol->tick()); ArticulationMap articulations = makeStandardArticulationMap(profile, eventTimestamp, duration); @@ -161,6 +166,11 @@ 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(); @@ -168,8 +178,7 @@ void PlaybackEventsRenderer::renderChordSymbol(const Harmony* chordSymbol, const voice_layer_idx_t voiceIdx = static_cast(chordSymbol->voice()); staff_layer_idx_t staffIdx = static_cast(chordSymbol->staffIdx()); - - Key key = chordSymbol->staff()->key(chordSymbol->tick()); + Key key = staff->key(chordSymbol->tick()); ArticulationMap articulations = makeStandardArticulationMap(profile, actualTimestamp, actualDuration);