Skip to content

Commit

Permalink
fix #48996: Crash when undoing tie. On paste, remove pending ties at …
Browse files Browse the repository at this point in the history
…the end of the selection
  • Loading branch information
lasconic committed Feb 26, 2015
1 parent 96c7028 commit a59103f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
5 changes: 1 addition & 4 deletions libmscore/note.cpp
Expand Up @@ -904,10 +904,7 @@ void Note::read(XmlReader& e)
tie->setTrack(track());
tie->read(e);
tie->setStartNote(this);
if (e.pasteMode())
score()->undo(new AddElement(tie));
else
_tieFor = tie;
_tieFor = tie;
}
else if (tag == "Fingering" || tag == "Text") { // Text is obsolete
Fingering* f = new Fingering(score());
Expand Down
15 changes: 15 additions & 0 deletions libmscore/paste.cpp
Expand Up @@ -188,10 +188,24 @@ bool Score::pasteStaff(XmlReader& e, Segment* dst, int dstStaff)
}
graceNotes.clear();
}
// delete pending ties, they are not selected when copy
if ((tick - dstTick) + cr->actualTicks() >= tickLen) {
if (cr->type() == Element::Type::CHORD) {
Chord* c = static_cast<Chord*>(cr);
for (Note* note: c->notes()) {
Tie* tie = note->tieFor();
if (tie) {
note->setTieFor(0);
delete tie;
}
}
}
}
//shorten last cr to fit in the space made by makeGap
if ((tick - dstTick) + cr->actualTicks() > tickLen) {
int newLength = tickLen - (tick - dstTick);
// check previous CR on same track, if it has tremolo, delete the tremolo
// we don't want a tremolo and two different chord durations
if (cr->type() == Element::Type::CHORD) {
Segment* s = tick2leftSegment(tick - 1);
if (s) {
Expand All @@ -204,6 +218,7 @@ bool Score::pasteStaff(XmlReader& e, Segment* dst, int dstStaff)
if (tr) {
tr->setChords(chrt, static_cast<Chord*>(cr));
chrt->remove(tr);
delete tr;
}
}
}
Expand Down
10 changes: 0 additions & 10 deletions libmscore/score.cpp
Expand Up @@ -69,7 +69,6 @@
#include "sym.h"
#include "rehearsalmark.h"
#include "breath.h"
#include "tie.h"

namespace Ms {

Expand Down Expand Up @@ -1558,15 +1557,6 @@ void Score::removeElement(Element* element)
break;

case Element::Type::CHORD:
{
Chord* c = static_cast<Chord*>(element);
for (Note* n : c->notes()) {
Tie* t = n->tieFor();
if (t)
n->remove(t);
}
}
// fall through
case Element::Type::REST:
{
ChordRest* cr = static_cast<ChordRest*>(element);
Expand Down

0 comments on commit a59103f

Please sign in to comment.