diff --git a/src/engraving/dom/measure.cpp b/src/engraving/dom/measure.cpp index 106a360200612..c87c9b20e475f 100644 --- a/src/engraving/dom/measure.cpp +++ b/src/engraving/dom/measure.cpp @@ -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. diff --git a/src/engraving/dom/measure.h b/src/engraving/dom/measure.h index 4d16c3b556e9e..30e111fc71d9b 100644 --- a/src/engraving/dom/measure.h +++ b/src/engraving/dom/measure.h @@ -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(); diff --git a/src/engraving/rw/read410/read410.cpp b/src/engraving/rw/read410/read410.cpp index 653ba4b1a730b..f7fc931127a4a 100644 --- a/src/engraving/rw/read410/read410.cpp +++ b/src/engraving/rw/read410/read410.cpp @@ -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;