Skip to content

Commit

Permalink
fix #106851: changing pitch on percussion staff crashes MuseScore
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Apr 21, 2016
1 parent 30f7de9 commit 069db44
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
29 changes: 18 additions & 11 deletions libmscore/chord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1603,8 +1603,9 @@ void Chord::cmdUpdateNotes(AccidentalState* as)
}

std::vector<Note*> 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
Expand All @@ -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;
}
}
}
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions libmscore/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Chord*>(cr);
if (cr->isChord()) {
Chord* chord = toChord(cr);
for (Chord* c : chord->graceNotes())
layoutCR0(c, mm, as);
if (!chord->isGrace())
Expand Down
4 changes: 2 additions & 2 deletions mscore/debugger/note.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>807</width>
<height>309</height>
<height>325</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -157,7 +157,7 @@
<bool>true</bool>
</property>
<property name="minimum">
<number>-99</number>
<number>-9999</number>
</property>
</widget>
</item>
Expand Down

0 comments on commit 069db44

Please sign in to comment.