Skip to content

Commit

Permalink
fix #296995: use a more reliable way to prevent layout from altering …
Browse files Browse the repository at this point in the history
…CmdState
  • Loading branch information
dmitrio95 authored and anatoly-os committed Nov 13, 2019
1 parent 4056e9a commit 824af4c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 0 additions & 2 deletions libmscore/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,9 @@ void Score::update(bool resetCmdState)
CmdState& cs = ms->cmdState();
ms->deletePostponed();
if (cs.layoutRange()) {
cs.lock();
for (Score* s : ms->scoreList())
s->doLayoutRange(cs.startTick(), cs.endTick());
updateAll = true;
cs.unlock();
}
}

Expand Down
13 changes: 13 additions & 0 deletions libmscore/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4334,12 +4334,25 @@ void Score::doLayout()
doLayoutRange(Fraction(0,1), Fraction(-1,1));
}

//---------------------------------------------------------
// CmdStateLocker
//---------------------------------------------------------

class CmdStateLocker {
Score* score;
public:
CmdStateLocker(Score* s) : score(s) { score->cmdState().lock(); }
~CmdStateLocker() { score->cmdState().unlock(); }
};

//---------------------------------------------------------
// doLayoutRange
//---------------------------------------------------------

void Score::doLayoutRange(const Fraction& st, const Fraction& et)
{
CmdStateLocker cmdStateLocker(this);

Fraction stick(st);
Fraction etick(et);
Q_ASSERT(!(stick == Fraction(-1,1) && etick == Fraction(-1,1)));
Expand Down

0 comments on commit 824af4c

Please sign in to comment.