Skip to content

Commit

Permalink
fix #295881: fix a crash on undoing adding an instrument in continuou…
Browse files Browse the repository at this point in the history
…s view
  • Loading branch information
dmitrio95 committed Oct 22, 2019
1 parent 696914f commit b51896e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
6 changes: 1 addition & 5 deletions libmscore/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1781,11 +1781,7 @@ System* Score::getNextSystem(LayoutContext& lc)
_systems.append(system);
if (!isVBox) {
int nstaves = Score::nstaves();
for (int i = system->staves()->size(); i < nstaves; ++i)
system->insertStaff(i);
int dn = system->staves()->size() - nstaves;
for (int i = 0; i < dn; ++i)
system->removeStaff(system->staves()->size()-1);
system->adjustStavesNumber(nstaves);
}
return system;
}
Expand Down
4 changes: 2 additions & 2 deletions libmscore/layoutlinear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ void Score::resetSystems(bool layoutAll, LayoutContext& lc)
System* system = new System(this);
_systems.push_back(system);
page->appendSystem(system);
for (int i = 0; i < nstaves(); ++i)
system->insertStaff(i);
system->adjustStavesNumber(nstaves());
}
else {
if (pages().isEmpty())
return;
page = pages().front();
System* system = systems().front();
system->clear();
system->adjustStavesNumber(nstaves());
}
lc.page = page;
}
Expand Down
13 changes: 13 additions & 0 deletions libmscore/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,19 @@ void System::removeStaff(int idx)
_staves.takeAt(idx);
}

//---------------------------------------------------------
// adjustStavesNumber
//---------------------------------------------------------

void System::adjustStavesNumber(int nstaves)
{
for (int i = _staves.size(); i < nstaves; ++i)
insertStaff(i);
const int dn = _staves.size() - nstaves;
for (int i = 0; i < dn; ++i)
removeStaff(_staves.size() - 1);
}

//---------------------------------------------------------
// layoutSystem
/// Layout the System
Expand Down
1 change: 1 addition & 0 deletions libmscore/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class System final : public Element {

SysStaff* insertStaff(int);
void removeStaff(int);
void adjustStavesNumber(int);

int y2staff(qreal y) const;
void setInstrumentNames(bool longName, Fraction tick = {0,1});
Expand Down

0 comments on commit b51896e

Please sign in to comment.