@@ -1507,7 +1507,8 @@ bool NotationInteraction::isDropSingleAccepted(const PointF& pos, Qt::KeyboardMo
15071507 return false ;
15081508}
15091509
1510- static void dropRangePosition (Score* score, const PointF& pos, Fraction tickLength, staff_idx_t * staffIdx, Segment** segment)
1510+ static void dropRangePosition (Score* score, const PointF& pos, Fraction tickLength, staff_idx_t numStaves, staff_idx_t * staffIdx,
1511+ Segment** segment)
15111512{
15121513 IF_ASSERT_FAILED (score && staffIdx && segment) {
15131514 return ;
@@ -1544,12 +1545,16 @@ static void dropRangePosition(Score* score, const PointF& pos, Fraction tickLeng
15441545 return ;
15451546 }
15461547
1548+ const staff_idx_t endStaffIdx = std::min (*staffIdx + numStaves, score->nstaves ());
1549+
15471550 // Add time tick anchors throughout these measures
15481551 for (MeasureBase* mb = startMeasure; mb && mb->tick () <= endMeasure->tick (); mb = mb->next ()) {
15491552 if (!mb->isMeasure ()) {
15501553 continue ;
15511554 }
1552- EditTimeTickAnchors::updateAnchors (toMeasure (mb), *staffIdx);
1555+ for (staff_idx_t i = 0 ; i < endStaffIdx; ++i) {
1556+ EditTimeTickAnchors::updateAnchors (toMeasure (mb), i);
1557+ }
15531558 }
15541559
15551560 // Get precise location using the newly created time tick anchors
@@ -1561,7 +1566,7 @@ static void dropRangePosition(Score* score, const PointF& pos, Fraction tickLeng
15611566 startTick = (*segment)->tick ();
15621567 endTick = startTick + tickLength;
15631568
1564- score->setShowAnchors (ShowAnchors (0 , *staffIdx, startTick, endTick,
1569+ score->setShowAnchors (ShowAnchors (0 , *staffIdx, *staffIdx + numStaves, startTick, endTick,
15651570 startMeasure->tick (), endMeasure->endTick ()));
15661571
15671572 // Invalidate BSP tree of affected pages
@@ -1597,7 +1602,7 @@ bool NotationInteraction::isDropRangeAccepted(const PointF& pos)
15971602 staff_idx_t staffIdx = muse::nidx;
15981603 Segment* segment = nullptr ;
15991604
1600- dropRangePosition (score (), pos, rdd.tickLength , &staffIdx, &segment);
1605+ dropRangePosition (score (), pos, rdd.tickLength , rdd. numStaves , &staffIdx, &segment);
16011606 if (staffIdx == muse::nidx || !segment) {
16021607 return false ;
16031608 }
@@ -1621,7 +1626,7 @@ bool NotationInteraction::isDropRangeAccepted(const PointF& pos)
16211626 return false ;
16221627 }
16231628
1624- const staff_idx_t endStaffIdx = staffIdx + rdd.numStaves ;
1629+ const staff_idx_t endStaffIdx = std::min ( staffIdx + rdd.numStaves , score ()-> nstaves ()) ;
16251630
16261631 rdd.dropRects = ScoreRangeUtilities::boundingArea (score (),
16271632 segment, endSegment,
@@ -1899,7 +1904,7 @@ bool NotationInteraction::dropRange(const QByteArray& data, const PointF& pos, b
18991904 staff_idx_t staffIdx = muse::nidx;
19001905 Segment* segment = nullptr ;
19011906
1902- dropRangePosition (score (), pos, rdd.tickLength , &staffIdx, &segment);
1907+ dropRangePosition (score (), pos, rdd.tickLength , rdd. numStaves , &staffIdx, &segment);
19031908 if (staffIdx == muse::nidx || !segment) {
19041909 return false ;
19051910 }
0 commit comments