Skip to content

Avoid state reset on paste #29393

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion src/engraving/dom/box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,6 @@ void FBox::init()

DEFER {
triggerLayout();
score()->setNeedLayoutFretBox(true);
};

clearElements();
Expand Down
5 changes: 0 additions & 5 deletions src/engraving/dom/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,6 @@ void Score::update(bool resetCmdState, bool layoutAllParts)

TRACEFUNC;

if (m_needLayoutFretBox) {
relayoutFretBox();
m_needLayoutFretBox = false;
}

bool updateAll = false;
{
MasterScore* ms = masterScore();
Expand Down
19 changes: 0 additions & 19 deletions src/engraving/dom/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7453,25 +7453,6 @@ void Score::rebuildFretBox()
}
}

void Score::relayoutFretBox()
{
FBox* fretBox = findFretBox();
if (!fretBox) {
return;
}

fretBox->triggerLayout();

for (EngravingObject* linkedObject : fretBox->linkList()) {
if (!linkedObject || !linkedObject->isFBox() || linkedObject == fretBox) {
continue;
}

FBox* box = toFBox(linkedObject);
box->triggerLayout();
}
}

//---------------------------------------------------------
// undoAddCR
//---------------------------------------------------------
Expand Down
5 changes: 0 additions & 5 deletions src/engraving/dom/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,11 +493,6 @@ void Score::setUpTempoMap()
m_needSetUpTempoMap = false;
}

void Score::setNeedLayoutFretBox(bool layout)
{
m_needLayoutFretBox = layout;
}

//---------------------------------------------------------
// fixTicks
/// updates tempomap and time sig map for a measure
Expand Down
3 changes: 0 additions & 3 deletions src/engraving/dom/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,6 @@ class Score : public EngravingObject, public muse::Injectable

void setUpTempoMapLater();
void setUpTempoMap();
void setNeedLayoutFretBox(bool layout);

EngravingItem* nextElement();
EngravingItem* prevElement();
Expand Down Expand Up @@ -1094,7 +1093,6 @@ class Score : public EngravingObject, public muse::Injectable
void updateSystemLocksOnCreateMMRests(Measure* first, Measure* last);

void rebuildFretBox();
void relayoutFretBox();

friend class Chord;

Expand Down Expand Up @@ -1245,7 +1243,6 @@ class Score : public EngravingObject, public muse::Injectable

bool m_isOpen = false;
bool m_needSetUpTempoMap = true;
bool m_needLayoutFretBox = false;

std::map<String, String> m_metaTags;

Expand Down
5 changes: 5 additions & 0 deletions src/engraving/dom/spanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1469,6 +1469,11 @@ track_idx_t Spanner::effectiveTrack2() const

void Spanner::triggerLayout() const
{
// Don't trigger layout until the tick is correctly set, otherwise is triggers layout of the entire score
if (m_tick.numerator() < 0) {
return;
}

// Spanners do not have parent even when added to a score, so can't check parent here
const track_idx_t tr2 = effectiveTrack2();
score()->setLayout(m_tick, m_tick + m_ticks, staffIdx(), track2staff(tr2), this);
Expand Down
1 change: 0 additions & 1 deletion src/engraving/rw/read400/read400.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,6 @@ bool Read400::pasteStaff(XmlReader& e, Segment* dst, staff_idx_t dstStaff, Fract
}

if (score->cmdState().layoutRange()) {
score->cmdState().reset();
score->setLayout(dstTick, dstTick + tickLen, dstStaff, endStaff, dst);
}

Expand Down
1 change: 0 additions & 1 deletion src/engraving/rw/read410/read410.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,6 @@ bool Read410::pasteStaff(XmlReader& e, Segment* dst, staff_idx_t dstStaff, Fract
}

if (score->cmdState().layoutRange()) {
score->cmdState().reset();
score->setLayout(dstTick, dstTick + tickLen, dstStaff, endStaff, dst);
}

Expand Down
1 change: 0 additions & 1 deletion src/engraving/rw/read460/read460.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,6 @@ bool Read460::pasteStaff(XmlReader& e, Segment* dst, staff_idx_t dstStaff, Fract
}

if (score->cmdState().layoutRange()) {
score->cmdState().reset();
score->setLayout(dstTick, dstTick + tickLen, dstStaff, endStaff, dst);
}

Expand Down
10 changes: 0 additions & 10 deletions src/notation/internal/notationinteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2202,16 +2202,6 @@ bool NotationInteraction::dropRange(const QByteArray& data, const PointF& pos, b
XmlReader e(data);
score()->pasteStaff(e, segment, staffIdx);

if (deleteSourceMaterial) {
// pasteStaff limits the layout range to just the destination region,
// but if the source material was deleted we must also layout the source region.
CmdState& cmdState = score()->cmdState();
cmdState.setTick(rdd.sourceTick);
cmdState.setTick(rdd.sourceTick + rdd.tickLength);
cmdState.setStaff(rdd.sourceStaffIdx);
cmdState.setStaff(rdd.sourceStaffIdx + rdd.numStaves);
}

endDrop();
apply();

Expand Down
Loading