From 8a1232524bc31df96a019e5d31cf440703fb8d1a Mon Sep 17 00:00:00 2001 From: Marc Sabatella Date: Sun, 3 Jan 2016 12:40:36 -0700 Subject: [PATCH] fix #92626: corruption when removing all existing staves and adding new ones --- libmscore/measure.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libmscore/measure.cpp b/libmscore/measure.cpp index 822304a7555d..edbb60908f65 100644 --- a/libmscore/measure.cpp +++ b/libmscore/measure.cpp @@ -1135,12 +1135,19 @@ void Measure::cmdAddStaves(int sStaff, int eStaff, bool createRest) // replicate time signature if (ts) { TimeSig* ots = 0; + bool constructed = false; for (int track = 0; track < staves.size() * VOICES; ++track) { if (ts->element(track)) { ots = static_cast(ts->element(track)); break; } } + if (!ots) { + // no time signature found; use measure length to construct one + ots = new TimeSig(score()); + ots->setSig(len()); + constructed = true; + } // do no replicate local time signatures if (ots && !ots->isLocal()) { TimeSig* timesig = new TimeSig(*ots); @@ -1149,6 +1156,8 @@ void Measure::cmdAddStaves(int sStaff, int eStaff, bool createRest) timesig->setSig(ots->sig(), ots->timeSigType()); timesig->setNeedLayout(true); score()->undoAddElement(timesig); + if (constructed) + delete ots; } } }