Skip to content

Commit 824af4c

Browse files
dmitrio95anatoly-os
authored andcommitted
fix #296995: use a more reliable way to prevent layout from altering CmdState
1 parent 4056e9a commit 824af4c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

libmscore/cmd.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,9 @@ void Score::update(bool resetCmdState)
277277
CmdState& cs = ms->cmdState();
278278
ms->deletePostponed();
279279
if (cs.layoutRange()) {
280-
cs.lock();
281280
for (Score* s : ms->scoreList())
282281
s->doLayoutRange(cs.startTick(), cs.endTick());
283282
updateAll = true;
284-
cs.unlock();
285283
}
286284
}
287285

libmscore/layout.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4334,12 +4334,25 @@ void Score::doLayout()
43344334
doLayoutRange(Fraction(0,1), Fraction(-1,1));
43354335
}
43364336

4337+
//---------------------------------------------------------
4338+
// CmdStateLocker
4339+
//---------------------------------------------------------
4340+
4341+
class CmdStateLocker {
4342+
Score* score;
4343+
public:
4344+
CmdStateLocker(Score* s) : score(s) { score->cmdState().lock(); }
4345+
~CmdStateLocker() { score->cmdState().unlock(); }
4346+
};
4347+
43374348
//---------------------------------------------------------
43384349
// doLayoutRange
43394350
//---------------------------------------------------------
43404351

43414352
void Score::doLayoutRange(const Fraction& st, const Fraction& et)
43424353
{
4354+
CmdStateLocker cmdStateLocker(this);
4355+
43434356
Fraction stick(st);
43444357
Fraction etick(et);
43454358
Q_ASSERT(!(stick == Fraction(-1,1) && etick == Fraction(-1,1)));

0 commit comments

Comments
 (0)