Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #25676: When pasting a dynamic, undoAdd a segment if it doesn't already exist #25686

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/engraving/dom/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,23 @@ Segment* Measure::getChordRestOrTimeTickSegment(const Fraction& f)
return seg;
}

Segment* Measure::undoGetChordRestOrTimeTickSegment(const Fraction& f)
{
Segment* seg = findSegment(SegmentType::ChordRest, f);
if (!seg) {
seg = findSegment(SegmentType::TimeTick, f);
}
if (!seg) {
if (f - tick() == ticks()) { // end of measure
seg = undoGetSegment(SegmentType::TimeTick, f);
} else {
seg = undoGetSegment(SegmentType::ChordRest, f);
}
}

return seg;
}

//---------------------------------------------------------
// getSegmentR
/// Get a segment of type st at relative tick position t.
Expand Down
1 change: 1 addition & 0 deletions src/engraving/dom/measure.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ class Measure final : public MeasureBase
Segment* findSegment(SegmentType st, const Fraction& f) const { return findSegmentR(st, f - tick()); }
Segment* undoGetSegment(SegmentType st, const Fraction& f) { return undoGetSegmentR(st, f - tick()); }
Segment* getSegment(SegmentType st, const Fraction& f) { return getSegmentR(st, f - tick()); }
Segment* undoGetChordRestOrTimeTickSegment(const Fraction& f);
Segment* getChordRestOrTimeTickSegment(const Fraction& f);

void connectTremolo();
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/rw/read410/read410.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ bool Read410::pasteStaff(XmlReader& e, Segment* dst, staff_idx_t dstStaff, Fract

Fraction tick = doScale ? (ctx.tick() - dstTick) * scale + dstTick : ctx.tick();
Measure* m = score->tick2measure(tick);
Segment* seg = m->getChordRestOrTimeTickSegment(tick);
Segment* seg = m->undoGetChordRestOrTimeTickSegment(tick);
el->setParent(seg);

// be sure to paste the element in the destination track;
Expand Down