From a4e462676568c05c00660b63ae2a392e563ce09c Mon Sep 17 00:00:00 2001 From: ws Date: Thu, 21 Feb 2013 13:34:47 +0100 Subject: [PATCH] fix #20120: crash in redo when vertical box changes system --- libmscore/system.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/libmscore/system.cpp b/libmscore/system.cpp index e8f4b5a6cd..98872e10ed 100644 --- a/libmscore/system.cpp +++ b/libmscore/system.cpp @@ -460,13 +460,18 @@ void System::clear() 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 return; if (!score()->showInstrumentNames()) { for (int staffIdx = 0; staffIdx < score()->nstaves(); ++staffIdx) { SysStaff* staff = _staves[staffIdx]; foreach(InstrumentName* t, staff->instrumentNames) - score()->undoRemoveElement(t); + //score()->undoRemoveElement(t); + score()->removeElement(t); } return; } @@ -476,7 +481,8 @@ void System::setInstrumentNames(bool longName) Staff* s = score()->staff(staffIdx); if (!s->isTop()) { foreach(InstrumentName* t, staff->instrumentNames) - score()->undoRemoveElement(t); + //score()->undoRemoveElement(t); + score()->removeElement(t); continue; } @@ -493,14 +499,16 @@ void System::setInstrumentNames(bool longName) iname->setParent(this); iname->setTrack(staffIdx * VOICES); iname->setSubtype(longName ? INSTRUMENT_NAME_LONG : INSTRUMENT_NAME_SHORT); - score()->undoAddElement(iname); + // score()->undoAddElement(iname); + score()->addElement(iname); } iname->setText(sn.name); iname->setLayoutPos(sn.pos); ++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); switch(el->type()) { case INSTRUMENT_NAME: +// qDebug(" staffIdx %d, staves %d", el->staffIdx(), _staves.size()); _staves[el->staffIdx()]->instrumentNames.append(static_cast(el)); break; + case BEAM: score()->add(el); break;