From 069db44e0ccb50283e3470a603752264c68fc2d3 Mon Sep 17 00:00:00 2001 From: ws Date: Thu, 21 Apr 2016 14:17:18 +0200 Subject: [PATCH] fix #106851: changing pitch on percussion staff crashes MuseScore --- libmscore/chord.cpp | 29 ++++++++++++++++++----------- libmscore/measure.cpp | 4 ++-- mscore/debugger/note.ui | 4 ++-- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/libmscore/chord.cpp b/libmscore/chord.cpp index 1e1f2213dc67f..bd4ce63d9c536 100644 --- a/libmscore/chord.cpp +++ b/libmscore/chord.cpp @@ -1603,8 +1603,9 @@ void Chord::cmdUpdateNotes(AccidentalState* as) } std::vector lnotes(notes()); // we need a copy! - for (Note* note : lnotes) { - if (staffGroup == StaffGroup::STANDARD) { + + if (staffGroup == StaffGroup::STANDARD) { + for (Note* note : lnotes) { if (note->tieBack()) { if (note->accidental() && note->tpc() == note->tieBack()->startNote()->tpc()) { // TODO: remove accidental only if note is not @@ -1614,19 +1615,25 @@ void Chord::cmdUpdateNotes(AccidentalState* as) } note->updateAccidental(as); } - else if (staffGroup == StaffGroup::PERCUSSION) { - const Instrument* instrument = part()->instrument(); - const Drumset* drumset = instrument->drumset(); - int pitch = note->pitch(); - if (drumset) { + } + else if (staffGroup == StaffGroup::PERCUSSION) { + const Instrument* instrument = part()->instrument(); + const Drumset* drumset = instrument->drumset(); + if (!drumset) + qWarning("no drumset"); + for (Note* note : lnotes) { + if (!drumset) + note->setLine(0); + else { + int pitch = note->pitch(); if (!drumset->isValid(pitch)) { - // qDebug("unmapped drum note %d", pitch); + note->setLine(0); + qWarning("unmapped drum note %d", pitch); } else if (!note->fixed()) { note->undoChangeProperty(P_ID::HEAD_GROUP, int(drumset->noteHead(pitch))); - // note->setHeadGroup(drumset->noteHead(pitch)); + // note->setHeadGroup(drumset->noteHead(pitch)); note->setLine(drumset->line(pitch)); - continue; } } } @@ -1704,7 +1711,7 @@ void Chord::layoutPitched() c->layoutPitched(); qreal _spatium = spatium(); - qreal _mag = staff()->mag(); + qreal _mag = staff() ? staff()->mag() : 1.0; // palette elements do not have a staff qreal dotNoteDistance = score()->styleP(StyleIdx::dotNoteDistance) * _mag; qreal minNoteDistance = score()->styleP(StyleIdx::minNoteDistance) * _mag; qreal minTieLength = score()->styleP(StyleIdx::MinTieLength) * _mag; diff --git a/libmscore/measure.cpp b/libmscore/measure.cpp index cc224db1eefc6..eac190463b9d2 100644 --- a/libmscore/measure.cpp +++ b/libmscore/measure.cpp @@ -2855,8 +2855,8 @@ void Measure::layoutCR0(ChordRest* cr, qreal mm, AccidentalState* as) if (cr->small()) m *= score()->styleD(StyleIdx::smallNoteMag); - if (cr->type() == Element::Type::CHORD) { - Chord* chord = static_cast(cr); + if (cr->isChord()) { + Chord* chord = toChord(cr); for (Chord* c : chord->graceNotes()) layoutCR0(c, mm, as); if (!chord->isGrace()) diff --git a/mscore/debugger/note.ui b/mscore/debugger/note.ui index 2ee181699c901..48a51f3f427ae 100644 --- a/mscore/debugger/note.ui +++ b/mscore/debugger/note.ui @@ -7,7 +7,7 @@ 0 0 807 - 309 + 325 @@ -157,7 +157,7 @@ true - -99 + -9999