fix #20120: crash in redo when vertical box changes system

This commit is contained in:
ws 2013-02-21 13:34:47 +01:00
parent 03eb808a20
commit a4e4626765

View file

@ -460,13 +460,18 @@ void System::clear()
void System::setInstrumentNames(bool longName) void System::setInstrumentNames(bool longName)
{ {
//
// remark: add/remove instrument names is not undo/redoable
// as add/remove of systems is not undoable
//
if (isVbox()) // ignore vbox if (isVbox()) // ignore vbox
return; return;
if (!score()->showInstrumentNames()) { if (!score()->showInstrumentNames()) {
for (int staffIdx = 0; staffIdx < score()->nstaves(); ++staffIdx) { for (int staffIdx = 0; staffIdx < score()->nstaves(); ++staffIdx) {
SysStaff* staff = _staves[staffIdx]; SysStaff* staff = _staves[staffIdx];
foreach(InstrumentName* t, staff->instrumentNames) foreach(InstrumentName* t, staff->instrumentNames)
score()->undoRemoveElement(t); //score()->undoRemoveElement(t);
score()->removeElement(t);
} }
return; return;
} }
@ -476,7 +481,8 @@ void System::setInstrumentNames(bool longName)
Staff* s = score()->staff(staffIdx); Staff* s = score()->staff(staffIdx);
if (!s->isTop()) { if (!s->isTop()) {
foreach(InstrumentName* t, staff->instrumentNames) foreach(InstrumentName* t, staff->instrumentNames)
score()->undoRemoveElement(t); //score()->undoRemoveElement(t);
score()->removeElement(t);
continue; continue;
} }
@ -493,14 +499,16 @@ void System::setInstrumentNames(bool longName)
iname->setParent(this); iname->setParent(this);
iname->setTrack(staffIdx * VOICES); iname->setTrack(staffIdx * VOICES);
iname->setSubtype(longName ? INSTRUMENT_NAME_LONG : INSTRUMENT_NAME_SHORT); iname->setSubtype(longName ? INSTRUMENT_NAME_LONG : INSTRUMENT_NAME_SHORT);
score()->undoAddElement(iname); // score()->undoAddElement(iname);
score()->addElement(iname);
} }
iname->setText(sn.name); iname->setText(sn.name);
iname->setLayoutPos(sn.pos); iname->setLayoutPos(sn.pos);
++idx; ++idx;
} }
for (; idx < staff->instrumentNames.size(); ++idx) for (; idx < staff->instrumentNames.size(); ++idx)
score()->undoRemoveElement(staff->instrumentNames[idx]); // score()->undoRemoveElement(staff->instrumentNames[idx]);
score()->removeElement(staff->instrumentNames[idx]);
} }
} }
@ -544,8 +552,10 @@ void System::add(Element* el)
el->setParent(this); el->setParent(this);
switch(el->type()) { switch(el->type()) {
case INSTRUMENT_NAME: case INSTRUMENT_NAME:
// qDebug(" staffIdx %d, staves %d", el->staffIdx(), _staves.size());
_staves[el->staffIdx()]->instrumentNames.append(static_cast<InstrumentName*>(el)); _staves[el->staffIdx()]->instrumentNames.append(static_cast<InstrumentName*>(el));
break; break;
case BEAM: case BEAM:
score()->add(el); score()->add(el);
break; break;