Skip to content

Commit

Permalink
fix #20624
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Jul 31, 2013
1 parent dd3eb6a commit 55b3286
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
9 changes: 5 additions & 4 deletions libmscore/edit.cpp
Expand Up @@ -1485,8 +1485,8 @@ Lyrics* Score::addLyrics()

void Score::cmdCreateTuplet(ChordRest* ocr, Tuplet* tuplet)
{
qDebug("createTuplet at %d <%s> duration <%s> ratio <%s> baseLen <%s>",
ocr->tick(), ocr->name(),
qDebug("cmdCreateTuplet at %d <%s> track %d duration <%s> ratio <%s> baseLen <%s>",
ocr->tick(), ocr->name(), ocr->track(),
qPrintable(ocr->duration().print()),
qPrintable(tuplet->ratio().print()),
qPrintable(tuplet->baseLen().fraction().print())
Expand Down Expand Up @@ -1515,13 +1515,14 @@ qDebug("createTuplet at %d <%s> duration <%s> ratio <%s> baseLen <%s>",
Fraction an = (tuplet->duration() * tuplet->ratio()) / tuplet->baseLen().fraction();
int actualNotes = an.numerator() / an.denominator();

tuplet->setTrack(track);
cr->setTuplet(tuplet);
cr->setTrack(track);
cr->setDurationType(tuplet->baseLen());
cr->setDuration(tuplet->baseLen().fraction());

qDebug("tuplet note duration %s actualNotes %d ticks %d",
qPrintable(tuplet->baseLen().name()), actualNotes, cr->actualTicks());
qDebug("tuplet note duration %s actualNotes %d ticks %d track %d tuplet track %d",
qPrintable(tuplet->baseLen().name()), actualNotes, cr->actualTicks(), track, tuplet->track());

undoAddCR(cr, measure, tick);

Expand Down
2 changes: 1 addition & 1 deletion libmscore/style.cpp
Expand Up @@ -967,7 +967,7 @@ void StyleData::load(XmlReader& e)
if (styleTypes.name(idx) == tag) {
switch(styleTypes.valueType(idx)) {
case ST_SPATIUM: set(idx, StyleVal(Spatium(val.toDouble()))); break;
case ST_DOUBLE: set(idx, StyleVal(qreal(val.toDouble()))); break;
case ST_DOUBLE: set(idx, StyleVal(qreal(val.toDouble()))); break;
case ST_BOOL: set(idx, StyleVal(bool(val.toInt()))); break;
case ST_INT: set(idx, StyleVal(val.toInt())); break;
case ST_DIRECTION: set(idx, StyleVal(MScore::Direction(val.toInt()))); break;
Expand Down
29 changes: 15 additions & 14 deletions libmscore/undo.cpp
Expand Up @@ -1109,19 +1109,17 @@ void Score::undoAddCR(ChordRest* cr, Measure* measure, int tick)
else
staffList.append(ostaff);
Segment::SegmentType segmentType = Segment::SegChordRest;

Tuplet* t = cr->tuplet();
foreach(Staff* staff, staffList) {
Score* score = staff->score();
Measure* m = (score == this) ? measure : score->tick2measure(tick);
// always create new segment for grace note:
Segment* seg = m->findSegment(segmentType, tick);
if (seg == 0) {
seg = new Segment(m, segmentType, tick);
score->undoAddElement(seg);
}
Segment* seg = m->undoGetSegment(segmentType, tick);

ChordRest* newcr = (staff == ostaff) ? cr : static_cast<ChordRest*>(cr->linkedClone());
newcr->setScore(score);
int staffIdx = score->staffIdx(staff);
int ntrack = staffIdx * VOICES + cr->voice();
int ntrack = staffIdx * VOICES + cr->voice();
newcr->setTrack(ntrack);
newcr->setParent(seg);

Expand All @@ -1133,26 +1131,29 @@ void Score::undoAddCR(ChordRest* cr, Measure* measure, int tick)
note->setTpcFromPitch();
}
}
if (cr->tuplet()) {
if (t) {
Tuplet* nt = 0;
Tuplet* t = cr->tuplet();
if (staff == ostaff)
nt = t;
else {
//if (t->elements().isEmpty() || t->elements().front() == cr) {
if (t->elements().front() == cr) {
if (t->elements().empty() || t->elements().front() == cr) {
nt = static_cast<Tuplet*>(t->linkedClone());
nt->setScore(score);
}
else {
LinkedElements* le = cr->tuplet()->links();
LinkedElements* le = t->links();
// search the linked tuplet
foreach(Element* e, *le) {
if (e->score() == score)
if (e->score() == score && e->track() == ntrack) {
nt = static_cast<Tuplet*>(e);
break;
}
}
if (nt == 0)
qDebug("linked tuplet not found");
}
newcr->setTuplet(nt);
}
newcr->setTuplet(nt);
}
undo(new AddElement(newcr));
score->updateAccidentals(m, staffIdx);
Expand Down

0 comments on commit 55b3286

Please sign in to comment.